angular - 在 ionic 2 中将 nav.push 与侧边菜单一起使用

标签 angular typescript ionic-framework ionic2 ionic3

我尝试在 ionic2 中制作一个小应用程序来了解它,但我遇到了导航问题。

事实上,我很清楚rootpage(更改nav.setRoot)和“普通”页面(添加nav.push)之间的区别)。事情是为了我的应用程序,我需要能够打开一个侧面菜单(如果我在 rootpage 上,这没问题,但对于第二种类型的页面则不行)并且能够返回(这对于推送页面是可以的,但对于根页面则不行)。

所以对我来说,这种类型的页面应该是推送而不是根页面,但是如何在这种类型的页面上重复侧边菜单?

谢谢。

最佳答案

编辑:

在你的 ion-menu 项中使用 persistent="true" 怎么样?就像您在 Ionic2 文档中看到的那样:

Persistent Menus Persistent menus display the MenuToggle button in the NavBar on all pages in the navigation stack. To make a menu persistent set persistent to true on the element. Note that this will only affect the MenuToggle button in the NavBar attached to the Menu with persistent set to true, any other MenuToggle buttons will not be affected.

因此您的 app.html 将是:

<ion-menu [content]="content" persistent="true">

  <ion-toolbar>
    <ion-title>Pages</ion-title>
  </ion-toolbar>

  <ion-content>
    <ion-list>
      <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
        {{p.title}}
      </button>
      <button menuClose ion-item (click)="logout()">Logout</button>
    </ion-list>
  </ion-content>

</ion-menu>

<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

关于angular - 在 ionic 2 中将 nav.push 与侧边菜单一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37905597/

相关文章:

javascript - Angular 5 原理图模板

javascript - 如何更改元素的 CSS 类并在单击时删除所有其他类

ios - Ionic 3 IOS App 不适用于首次启动,但在强制终止并启动后可以运行

angular - 如何减小 ionic2 中捆绑文件的大小?

android - 错误 ionic 构建android

javascript - 在另一个类中调用函数时, typescript 函数返回未定义

angular - 未使用的表达式,需要赋值或函数调用 Promise 函数中的 Angular lint 错误

angular - Typescript 将时间戳转换为 mm-dd 格式

javascript - 通过网络发送的字符串化 Json 无法正确解析

angular - 如何使用 TypeScript 在 Angular 2 中根据出生日期计算年龄