【问题标题】:Ionic 3 Navigation New page hiddenIonic 3 Navigation 隐藏新页面
【发布时间】:2018-02-27 08:22:39
【问题描述】:

我正在使用 ionic 3.10.3 我的根页面是 loginPage,然后在用户验证后将其重定向到 HomeViewPage,如下所示

this.nav.setRoot(HomeViewPage);

现在没问题,但是在 HomeViewPage 如果用户点击添加按钮,它必须重定向到 NewItemPage 我尝试使用

    this.nav.setRoot(NewItemPage, {itemID: _id, isNew: _isNew});

    this.nav.push(NewItemPage, {itemID: _id, isNew: _isNew});

下面是新功能

newItem(){
this.events.publish('apps:viewItem', this.handlerService.getNewID(), "1");
}

这是 app.component.ts 中接收事件的代码

this.events.subscribe('apps:viewItem', (_id, _isNew) => {
this.menu.close();
this.rootPage = NewItemPage;
this.nav.setRoot(NewItemPage, {itemID: _id, isNew: _isNew}).then(()=>{
  this.nav.popToRoot();
}).catch(err=>{
  alert("NewItemPage Error : " + err.toString());
});

});

但仍然在 HomeViewPage 中,即使我多次单击该按钮 但是当我点击返回按钮时,它返回到 NewItemPage 但现在数据存在。

任何帮助

【问题讨论】:

  • 请从 homeViewPage.ts 中发布一些代码
  • 为什么不从 homeViewPage.ts 中导航到 newItemPage?
  • 我得到了同样的结果
  • 感谢您的帮助@Sonicd300 我解决了它

标签: ionic-framework ionic3


【解决方案1】:

问题出在 NewItemPage 中,我使用了一个空对象属性

<ion-item>
  <ion-label>Activity Type</ion-label>
  <ion-select [(ngModel)]="handlerService.dataService.item.activityType">
    <ion-option *ngFor="let g of handlerService.dataService.activityTypes" value="{{g.id}}">{{ g.name }}</ion-option>
  </ion-select>
</ion-item>

handlerService.dataService.item 是一个必须初始化的对象

【讨论】:

    猜你喜欢
    • 2017-11-18
    • 1970-01-01
    • 2018-10-08
    • 2017-02-22
    • 2019-02-23
    • 1970-01-01
    • 2019-09-01
    • 2018-08-29
    • 1970-01-01
    相关资源
    最近更新 更多