我正在学习angularjs2,和/还使用离子2! 离子我创建一个侧面菜单:从应用程序Ionic2更新页面视图
/app.html:
<ion-content>
<ion-item-group>
<ion-item-divider light>Cats</ion-item-divider>
<ion-item *ngFor="#cat of categories" (click)="filter('category', cat.id)">{{cat.name}}</ion-item>
</ion-item-group>
当我在这些类别的点击,我要发送的分类编号,以我的一个网页(主页)。
我正在尝试设置在app.js价值HomePage类:
filter(key, value){
HomePage.prototype.setFilters(value); }
而且在首页类读取值:
/home/home.js:
setFilters(value) {
this.ViewValue = value;
console.log(this.ViewValue);
}
问题是,无法在HomePage视图中打印该值。 我想有: /home/home.html:
<ion-content class="getting-started">
Selected category:
{{ViewValue}}
</ion-content>
当我在左边菜单中的任何类别单击,在ViewValue不会改变。 当我运行console.log时,我可以获取我的类别,但它不会在视图中更改。
我在做什么错了? 还是有更好的方法来做到这一点?