В настоящее время я столкнулся с проблемой с моим Ionic-приложением. Я пытаюсь отфильтровать ионные карты на странице из бокового меню, определенного из (app.html). Это школьный проект для моей программы стажировки, и я был бы очень признателен за помощь. Страница выглядит так: Это моя страница с массивом для фильтрации и Это мой фильтр бокового меню
Мой код для страницы массива выглядит следующим образом, заранее спасибо:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, MenuController } from 'ionic-angular';
import { LocationsPage } from "../locations/locations";
import { AngularFireAuth } from "angularfire2/auth";
import { ToastController } from "ionic-angular";
import { RestPage } from "../rest/rest";
/**
* Generated class for the ContentPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-content',
templateUrl: 'content.html',
})
export class ContentPage {
modifiedData: any;
originalData: any;
constructor(private toast:ToastController,private afAuth: AngularFireAuth,public navCtrl: NavController, public navParams: NavParams, public menuCtrl: MenuController) {
this.navCtrl = navCtrl;
this.menuCtrl = menuCtrl;
// this.menuCtrl.enable(true, 'myMenu');
//array for the display of cards
//properties defined about the cards include:
//name-name of the Restaurant
//image-image to be used for the card
//text-text for the card
//PushPage-for pushing a specific page
//Price - defines price of a restaurant
// Cusisine - defines a restaurants Cuisine
//PAGE: SAME AS PUSHPAGE
this.originalData=[
{name:'Fairmont Hotel',image:'assets/images/fairmont.jpg',text:'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', PushPage: 'RestPage',Price: 'low', Cuisine:'Kenyan',Page: RestPage},
{name:'MarymountHotel',image:'assets/images/fairmont.jpg',text:'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', PushPage: 'RestPage',Price: 'Midrange',Cuisine:'Ethiopian', Page: RestPage}
];
this.modifiedData=JSON.parse(JSON.stringify(this.originalData));
}
//toast message to welcome a user to the app
ionViewWillLoad() {
this.afAuth.authState.subscribe(data =>{
if(data.email && data.uid){
this.toast.create({
message:'welcome to Rest',
duration: 3000
}).present();
}
})
}
//onclick event
itemSelected (PushPage) {
//alert(page);
var page = this.originalData.filter(function(it) {
return it.PushPage == PushPage
})[0].Page
//alert(page);
this.navCtrl.push(page);
}
//reset function
reset(){
this.modifiedData = JSON.parse(JSON.stringify(this.originalData));
}
//filtering function
filter(){
this.modifiedData=this.modifiedData.filter((rest)=>
{ return rest.Cuisine=='Kenyan'});
}
//toggel menu function
toggleLeftMenu() {
this.menuCtrl.toggle('left');
}
toggleRightMenu() {
this.menuCtrl.toggle('right');
}
//function that pushes from FAB button to LocationsPage
Locations(){
this.navCtrl.push(LocationsPage);
}
//function directing to the rest page that contains restaurant details
Rest(){
this.navCtrl.push(RestPage);
}
}
Код для бокового меню следующий:
<ion-menu side="left" [content]="content">
<ion-header id="background">
<ion-avatar item-start>
<img src="">
</ion-avatar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item (click)="openPage(homePage)">
Reservations
</button>
<button ion-item (click)="openPage(friendsPage)">
Settings
</button>
</ion-list>
</ion-content>
</ion-menu>
<!-- second sidemenu -->
<ion-menu side="right" [content]="content">
<ion-header id="background2">
</ion-header>
<ion-content>
<ion-item>
<p>Im looking for:</p>
<ion-label stacked>Cuisine:</ion-label>
<ion-select [(ngModel)]="gender">
<ion-option value="K">Kenyan</ion-option>
<ion-option value="E">Ethiopian</ion-option>
<ion-option value="I">Indian</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label stacked>Vibe:</ion-label>
<ion-select [(ngModel)]="Vibe">
<ion-option value="C">Chilled</ion-option>
<ion-option value="F">Formal</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label stacked>price:</ion-label>
<ion-select [(ngModel)]="Price">
<ion-option value="L">Low</ion-option>
<ion-option value="M">Midrange</ion-option>
<ion-option value="H">HighPriced</ion-option>
</ion-select>
</ion-item>
<!-- grid for placing the buttons -->
<!-- first grid for the reset button -->
<ion-grid>
<ion-row>
<ion-col col-6>
<button ion-button color="secondary" outline (click)='reset()'>Reset</button>
</ion-col>
<!-- second column for the apply button -->
<ion-col col-6>
<button ion-button color="secondary" outline (click)='filter(rest)' >Apply </button>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
</ion-menu>
<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content ></ion-nav>