带有离子框架的angularjs中的奇怪导航行为

Strange navigation behavior in angularjs with ionic framework

本文关键字:导航 航行 angularjs 框架      更新时间:2023-09-26

demo 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 路由器文档了解更多信息。

您还必须将默认状态更改为$urlRouterProvider.otherwise('home');(而不是"/home")。

这是一个有效的代码笔 http://codepen.io/anon/pen/ogjRwP