Ionic - SearchBar with Mysql Script


#21

Firstly, Your function doesnt make any sense. I cant find this.items in your declarations where have u declared it??
I think you need to learn how the filter array function works. Secondly u need to initiate the function filterItems() on change event in text box.


#22

Sorry i am all confused thats why i asked you to post the whole search.ts file.

you mean i should declared it like this

   ```

public items: any;


#23

It works now but i anot getting the results it should sort. I am getting the same results regardless what i type in the searchbar

I want it to sort like autocomplete. to show results of what i type in the search bar

search.ts

 @Component({ selector: "page-search", templateUrl: "search.html" })
  export class SearchPage {
  filter: string = '';
  public userDetails: any;
  public resposeData: any;
  public dataSet: any;
  public userSet: any;
  public mediaSet: any;
  public noRecords: boolean;
   userPostData = {
     uid: "",
     token: "",
     username: "",
     bio: ""
  };
 constructor(
     public common: Common,
     public navCtrl: NavController,
     public app: App,
     public menu: MenuController,
     public authService: AuthService,
     public http: Http,
     platform: Platform,
     statusBar: StatusBar,
     splashScreen: SplashScreen
 ) {
     this.initializeItems();
     this.mostmediaList();
  }
 initializeItems() {
     return this.userPostData;
 }
           getItems(ev: any) {

              this.initializeItems();
              let val = ev.target.value;

              if (val && val.trim() != '') {
                  this.authService.postData(this.userPostData, "userGroupSearch").then(
                      result => {
                          this.resposeData = result;
                          if (this.resposeData.allArtistsData) {
                              this.userSet = this.resposeData.allArtistsData;
                                  console.log(this.userSet);

                          } else {
                              console.log("No access");
                          }
                      },
                  );
              }
          }

What do you think @abhishekpatilxyz