2016-04-19 4 views
3

paramsとquery paramsの両方でui-srefを使用して角型アプリケーション上の別のルートへのリンクを動的に構築する必要があります。例:私はparamsとui-srefに両方のクエリを渡す必要があります

<a class="clr-secondary" ui-sref="app.topic.individual.conversation.single 
({cid:comment.activityItemId, cid:itemId})">{{comment.subject}}</a> 

これは私が全体のURLは次のようになりますまた、このの最後にクエリパラメータを追加する必要が

www.website.com/pass/11/conversations/178 

ようになりますリンクを構築

www.website.com/pass/11/conversations/178?comment_id=126 

答えて

3

uiルータのconfigのURLにクエリパラメータを追加します。

.state('yourstate', { 
    url: '/pass/:activityId/conversations/:conversationId?comment_id', 
    templateUrl: 'path/to/template', 
    controller: 'YourController' 
}); 

他のパラメータを渡すのと同じようにcomment_idを渡します。

<a class="clr-secondary" ui-sref="app.topic.individual.conversation.single 
({activityId:comment.activityItemId, conversationId:itemId, comment_id: 126})">{{comment.subject}}</a> 
関連する問題