【问题标题】:Ionic2 menuToggle is not working after Modal.presentIonic2 menuToggle 在 Modal.present 之后不起作用
【发布时间】:2018-01-21 22:50:03
【问题描述】:

我的侧边菜单或菜单切换代码位于 app.compnent.ts 中。在我单击模态之前,此菜单切换在所有页面中都可以正常工作。单击模态按钮后,MenuToggle 不起作用。我不确定确切的问题是什么。请问有什么建议吗?

菜单:

<ion-icon name="menu" menuToggle float-left margin-right></ion-icon>

页面A:

pageBModal() {
  let modal = this.modalCtrl.create(PageB);
  modal.present();
}

页面B:

  closeModal() {
    this.viewCtrl.dismiss();
    this.navCtrl.setRoot(DashBoardPage);
  }

【问题讨论】:

标签: ionic2 angular2-modal


【解决方案1】:

你可以使用 MenuController

import { MenuController } from 'ionic-angular';
constructor(public menuCtrl: MenuController) {
 }  
     If you want to close menu please use close() event

      this.menuCtrl.close()

     If you want to open menu please use open() event

      this.menuCtrl.open();

【讨论】:

    【解决方案2】:

    即使我也遇到过同样的问题。

    我已经使用Events 解决了这个问题。

    如果您尝试从模式导航页面,您将面临上述问题。(侧边菜单不起作用)。不要从modal ts 导航,而是尝试使用Eventsparent ts 导航。

    例如:

    Parent ts :
    
    events.subscribe('modal:finished', (page) => {
    
        if(page == 'yourpage') {
          this.navCtrl.push(YourPage);
        }
    
      });
    

    模态ts:

    this.events.publish('modal:finished', 'yourpage');
    

    您可以在模态关闭后从需要重定向的模态发送。根据这个条件,你可以重定向到任何你想要的地方。

    希望对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-19
      相关资源
      最近更新 更多