我想使用各种条件过滤对象的结果
我对IONIC还是很陌生,并希望完成过滤结果的任务
constructor(public navCtrl: NavController, public navParams: NavParams, private searchServ : SearchService,) {
this.allCreativeUsers();
}
allCreativeUsers() {
this.searchServ.getAllCreatives().then(
resp => {
console.log( typeof (resp));
console.log(resp);
this.allPeople = resp;
}
);
}
filterItems(ev: any) {
let val = ev.target.value;
if (val && val.trim() !== '') {
// Get The users from the Object Result and
}
}
当我开始输入某人的姓名时,我希望能够过滤对象并在列表中显示该人的姓名。
答案 0 :(得分:0)
这将过滤:
filterdata:any
constructor(public navCtrl: NavController, public navParams: NavParams, private
searchServ : SearchService,) {
this.allCreativeUsers();
}
allCreativeUsers() {
this.searchServ.getAllCreatives().then(
resp => {
console.log( typeof (resp));
console.log(resp);
this.allPeople = this.filterdata = resp;
}
);
}
filterItems(ev: any) {
let val = ev.target.value;
if (val && val.trim() !== '') {
// Get The users from the Object Result and
this.allPeople = this.filterdata.filter(r =>
(<string>r.route).includes(val));
}
}