Ionic:了解导航和路由

Ionic: Understanding navigation and routing

我正在学习 Ionic 中的导航和路由 http://learn.ionicframework.com/formulas/navigation-and-routing-part-1/

&我想了解映射,我没有从文档中清楚地了解它。

以下代码来自我的 app.js

app.config(function($stateProvider, $urlRouterProvider) {
      console.log('In Config');
      $urlRouterProvider.otherwise('/')

       $stateProvider.state('home', {
           url: '/home',
           views: {
               home: {
                   templateUrl: 'home.html'
               }
           }
         })
       })

& 以下代码来自 Index.html

<ion-tabs class="tabs-positive">
    <ion-tab icon="ion-home" ui-sref="home">
      <ion-nav-view name="home"></ion-nav-view>
    </ion-tab>

我的理解是 ui-serif 与状态名称映射。我不知道 url、templateUrl 和 ion-nav 视图名称是如何相互关联或相互映射的,因为如果我更改其中任何一个,我的应用程序将无法运行。

让我稍微改变一下你的例子,这样你就能理解得更多一点:

 $stateProvider.state('homeState', {
           url: '/homeUri',
           views: {
               homeName: {
                   templateUrl: 'home.html'
               }
           }
         })

在您的页面中这样引用:

  <ion-tab icon="ion-home">
      <ion-nav-view name="homeName"></ion-nav-view>
    </ion-tab>

或者您可以使用 href 访问它:

<a href="{{homeUri}}">

或使用ui-路由器路由

<a ui-sref="homeState">