This is my code:
items:any[] = [];
ngOnInit() {
this.setItems();
}
setItems() {
this.items;
}
filterItems(ev: any) {
this.setItems();
let val = ev.target.value;
if (val && val.trim() !== '') {
this.items = this.items.filter(function(item) {
return item.toLowerCase().includes(val.toLowerCase());
});
}
}
i’m array push from here:
ionViewDidLoad() {
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let options = new RequestOptions({ headers: headers });
this.http.get(myurl+"/leadlistingusers");
.subscribe((res:Response)=>{
let dataTemp = res.json(); //dataTemp is the json object you showed me
this.mydata = dataTemp.viewleadusers; //contains a [] object with all yours user
for(let i = 0; i < this.mydata.length; i++){
let a = this.mydata[i].userName;
let b= this.mydata[i].userID;
alert(b);
alert(a);
this.items.push({
"userID": b,
"userName":a
});
}
})
};
How can i fix that.