演示http://codepen.io/anon/pen/qEOJBp
我可以通过以下链接从第1页导航到第2页:<a href="#/threadContent">GO</a>
但是使用<a href="#/home">Back</a>
无法从第2页返回第1页?我想知道为什么?该代码对我来说看起来很完美:
<ion-nav-view name="home"></ion-nav-view>
<ion-nav-view name="threadContent"></ion-nav-view>
<script type="text/ng-template" id="home.html">
<ion-view name="home">
<ion-content>
<h2>Home Page</h2>
<p>Here is the main route for the app.</p>
<a href="#/threadContent">GO</a>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="threadContent.html">
<ion-view name="threadContent" title="Thread Content">
<ion-content>
<a href="#/home">Back</a>
<h2>Using the app</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis architecto hic officia quasi excepturi sequi deleniti maiores consectetur veritatis sint?</p>
</ion-content>
</ion-view>
</script>
最佳答案
我认为如果不需要,则不应使用命名视图。如果我了解您想要什么,那么您只需要在页面中添加一个<ion-nav-view></ion-nav-view>
。
仅当您希望状态修改页面的多个区域时,才需要命名视图。请参见ui-router docs for more。
您还必须将默认状态更改为$urlRouterProvider.otherwise('home');
(而不是“ / home”)。
这是一个有效的Codepen http://codepen.io/anon/pen/ogjRwP
关于javascript - 带有 ionic 框架的angularjs中的奇怪导航行为,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27294136/