.state('app.post', {
url: "/post/:postId",
views: {
'menuContent' :{
templateUrl: 'templates/postPages/viewPost.html',
controller: 'ViewPostController'
}
}
})
.state('app.post.edit', {
url: "/edit/:postId",
views: {
'menuContent@app' :{
templateUrl: 'templates/postPages/editPost.html',
controller: 'EditPostController'
}
}
})
.state('app.post.comments', {
url: "/comments/:postId",
views: {
'menuContent@app' :{
templateUrl: 'templates/postPages/post-comments.html',
controller: 'PostCommentsController'
}
}
}) 我有这个
<a class="tab-item" ui-sref="app.post.comments({postId:'{{post.id}}'})">
<i class="icon ion-chatbox"></i>
Comment
</a>它的渲染方式如下:
<a class="tab-item" ui-sref="app.post.comments({postId:'306cc780-71db-11e5-b49b-7bdc2a9aa3c7'})" href="#/app/post//comments/">
<i class="icon ion-chatbox"></i>
Comment
</a>在href中缺少post。
发布于 2015-10-21 17:57:30
在app.post中的url中提到app.post就足够了,就像url: "/post/:postId",,在app.post.edit & app.post.comments中,应该只有像/edit和/comments这样的url。
因此,在传递postId时,它只能与父post合并。
则您的ui-sref不应该有内插。
ui-sref="app.post.comments({postId: post.id})"将呈现为
href="#/app/post/306cc780-71db-11e5-b49b-7bdc2a9aa3c7/comments"国家
.state('app.post', {
url: "/post/:postId",
views: {
'menuContent' :{
templateUrl: 'templates/postPages/viewPost.html',
controller: 'ViewPostController'
}
}
})
.state('app.post.edit', {
url: "/edit",
views: {
'menuContent@app' :{
templateUrl: 'templates/postPages/editPost.html',
controller: 'EditPostController'
}
}
})
.state('app.post.comments', {
url: "/comments",
views: {
'menuContent@app' :{
templateUrl: 'templates/postPages/post-comments.html',
controller: 'PostCommentsController'
}
}
}) https://stackoverflow.com/questions/33266061
复制相似问题