2015-10-21 53 views
0
.state('app.post', { 
    url: "/post/:postId", 
    views: { 
     'menuContent' :{ 
     templateUrl: 'templates/postPages/viewPost.html', 
     controller: 'ViewPostController' 
     } 
    } 
    }) 

    .state('app.post.edit', { 
    url: "/edit/:postId", 
    views: { 
     '[email protected]' :{ 
     templateUrl: 'templates/postPages/editPost.html', 
     controller: 'EditPostController' 
     } 
    } 
    }) 

    .state('app.post.comments', { 
    url: "/comments/:postId", 
    views: { 
     '[email protected]' :{ 
     templateUrl: 'templates/postPages/post-comments.html', 
     controller: 'PostCommentsController' 
     } 
    } 
    }) 

我有這個UI-SREF不正常呈現

<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

回答

0

app.post提起postId的URL裏面足夠像url: "/post/:postId",,在app.post.edit & app.post.comments應該只有url s像/edit & /comments

因此,雖然通過postId它只與父職位合併。

那麼你的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: { 
     '[email protected]' :{ 
     templateUrl: 'templates/postPages/editPost.html', 
     controller: 'EditPostController' 
     } 
    } 
}) 
.state('app.post.comments', { 
    url: "/comments", 
    views: { 
     '[email protected]' :{ 
     templateUrl: 'templates/postPages/post-comments.html', 
     controller: 'PostCommentsController' 
     } 
    } 
}) 
+0

@Manish單擊向上箭頭,如果它確實幫助。 。 –