【问题标题】:Ionic: Understanding navigation and routingIonic:了解导航和路由
【发布时间】:2015-06-17 19:44:13
【问题描述】:

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

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

以下代码来自我的 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 视图名称是如何相互关联或相互映射的,因为如果我更改其中任何一个,我的应用程序将无法运行。

【问题讨论】:

    标签: angularjs ionic-framework ionic


    【解决方案1】:

    让我稍微改变一下你的例子,以便你能理解更多:

     $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-router 路由

    <a ui-sref="homeState">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      • 2016-11-14
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多