【问题标题】:ui-router - nested statesui-router - 嵌套状态
【发布时间】:2014-12-16 18:08:50
【问题描述】:

我们有以下代码:

app.js

.state('app.single', {
      url: "/paths/:pathId",
      views: {
        'menuContent' :{
          templateUrl: "templates/path.html",
          controller: 'PathCtrl'
        }
      }
   })

.state('app.single.comments', {
      url: "/comments",
      views: {
        'menuContent' :{
          templateUrl: "templates/comments.html",
          controller: 'CommentsCtrl'
        }
      }
    });
$urlRouterProvider.otherwise('/app/paths');

path.html:

 <a class="tab-item" href="#/app/paths/{{path.pathid}}/comments">
    <i class="icon ion-chatbox"></i>
    View Comments
 </a>

但是,当我单击视图评论时,它不会显示将由templates/comments.html 生成的视图。它停留在当前视图/path/:pathId

【问题讨论】:

  • 您是否在 path.html 中包含了 ui-view 标签?
  • @cbass 您介意详细说明一下吗?我正在开发一个离子框架应用程序,但我根本没有 ui-view。我正在使用 ion-view 代替
  • 那么你如何显示你的其他子视图?
  • 在 path.html 中:
  • 能否提供plunker或jsFiddle链接?

标签: angularjs ionic-framework angular-ui-router


【解决方案1】:

app.js 中的代码应该是:

.state('app.single.comments', {
   url: "/comments",
   views: {
     'menuContent@app' :{
       templateUrl: "templates/comments.html",
       controller: 'CommentsCtrl'
     }
   }
 });

【讨论】:

  • 谢谢!这很有帮助:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-22
  • 2015-03-11
  • 1970-01-01
相关资源
最近更新 更多