【发布时间】:2016-10-07 19:38:34
【问题描述】:
ion-nav-view 指令的示例代码实际上并未显示其用法。 所以我不确定如何使用它。 这是文档的链接:
http://ionicframework.com/docs/api/directive/ionNavView/
在 USAGE 标题下是这样写的:
在应用启动时,$stateProvider 会查看 url,看是否匹配 索引状态,然后尝试将 home.html 加载到 .
页面由给定的 URL 加载。创建模板的一种简单方法 在 Angular 中是将它们直接放入您的 HTML 文件并使用 句法。所以这是一种放置方式 home.html 进入我们的应用程序:
<script id="home" type="text/ng-template">
<!-- The title of the ion-view will be shown on the navbar -->
<ion-view view-title="Home">
<ion-content ng-controller="HomeCtrl">
<!-- The content of the page -->
<a href="#/music">Go to music page!</a>
</ion-content>
</ion-view>
</script>
这样做很好,因为模板将被缓存得非常快 加载,而不必从网络中获取它们。
我是否将所有这些都嵌套在 ion-nav-view 指令中?我感到困惑的另一个原因是因为在框架提供的一个 ionic 模板中,我看到 ion-nav-view 打开和关闭,中间没有任何内容(下面的代码是直接从 Ionic 的一个模板复制和粘贴的):
<body ng-app="myApp">
<!--
The nav bar that will be updated as we navigate between views.
-->
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
</body>
【问题讨论】:
标签: ionic-framework nav ionic-view