Ionic v2 中的布局页面

Layout page in Ionic v2

我想在我的应用程序(使用 Ionic v2 构建)中有一个布局页面。因为我希望每个页面都有我的导航栏和侧边菜单,所以我认为没有必要将它们添加到我项目的所有页面,对吗?

例如:ASP.NET 有网站的母版页,其中包含必须出现在每个页面上的组件。

有谁知道是否有简单的方法可以做到这一点?

有一个 Ionic 2 sidemenu starter,这是一个完美的启动器,可以让您按照需要开始使用您的应用程序。 Follow this link

它有侧边菜单组件,您可以在顶部构建并根据需要添加页面

I think it's unnecessary to add those to all the page's of my project, right?

sidemenu 内容只需添加一次,在 app.html 文件中。但是关于导航栏,正如您在 中看到的那样,@mhartington(来自 Ionic Team)说:

There is no way to create a global ion-navbar, as this is done on purpose. The point of having a navbar defined for each component is so that we can properly animate the titles, navbar background color (if you change them) and animate other properties needed.

以及关于创建自定义指令以避免重复 ion-navbar html 代码(我想这就是您的想法):

That will still creat errors with how angular2 content projection works. We have several issues that have been open when people try this and the best answer is to not do it.