ui路由器-嵌套状态

问题描述 投票:1回答:1

我们有以下代码:

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

enter image description here

angularjs ionic-framework angular-ui-router
1个回答
2
投票

app.js中的代码应该为:

.state('app.single.comments', {
   url: "/comments",
   views: {
     'menuContent@app' :{
       templateUrl: "templates/comments.html",
       controller: 'CommentsCtrl'
     }
   }
 });
© www.soinside.com 2019 - 2024. All rights reserved.