Javascript 离子火基中的角度滤波数据
我想用angular创建一个带有ionic firebase的搜索栏。但我并没有解决这个问题,因为当我在搜索栏中键入时,听起来好像没有调用filterList函数,或者我不知道到底是什么问题Javascript 离子火基中的角度滤波数据,javascript,angular,ionic-framework,firebase-realtime-database,angularfire2,Javascript,Angular,Ionic Framework,Firebase Realtime Database,Angularfire2,我想用angular创建一个带有ionic firebase的搜索栏。但我并没有解决这个问题,因为当我在搜索栏中键入时,听起来好像没有调用filterList函数,或者我不知道到底是什么问题 export class Tab1Page implements OnInit{ public grantsList: any[]; public loadedGrantsList: any[]; constructor(private dataService: DataService, pub
export class Tab1Page implements OnInit{
public grantsList: any[];
public loadedGrantsList: any[];
constructor(private dataService: DataService, public afdm: AngularFireDatabase ) {
}
ngOnInit(){
this.afdm.list('/grant').valueChanges().subscribe(grantsList => {
this.grantsList = grantsList;
this.loadedGrantsList = grantsList;
//console.log(this.grantsList)
});
}
initializeItems(): void {
this.grantsList = this.loadedGrantsList;
}
filterList(evt) {
this.initializeItems();
const searchTerm = evt.srcElement.value;
if (!searchTerm) {
return;
}
this.grantsList = this.grantsList.filter(currentGoal => {
if (currentGoal.title && searchTerm) {
if (currentGoal.title.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1) {
return true;
}
return false;
}
});
}
}
这是我的看法
<ion-header>
<ion-toolbar color="primary">
<ion-title>
Home
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-searchbar
showcancelbutton=""
(ioninput)="filterList($event)"
></ion-searchbar>
<ion-list>
<ion-item button *ngFor="let data of grantsList">
<ion-label class="ion-text-wrap">
<h3>{{data.title}}</h3>
<p>Type: {{data.Category}}</p>
<p>Deadline: {{data.Deadline}}</p>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
家
{{data.title}
类型:{{data.Category}
截止日期:{data.Deadline}
我想根据标题过滤搜索栏列表@RyanKelly问道,你有没有解决过这个问题?我正在使用来自该网站的相同代码,并且有相同的问题被困在该网站上多年days@RyanKelly他问,你有没有修过这个?我正在使用来自该网站的相同代码,并且有相同的问题已经在上面停留了好几天