2017-01-05 9 views
0

私は、ユーザーがクリックできるようにしたい、4つのフィルタリングされたシナリオを持っています。私はそれぞれのシナリオに対して異なるng-repeatフィルターを持っています。ng-clickでng-repeatシナリオをフィルタリングした角度変化

<div ng-model="topic0" ng-repeat="post in postCtrl.getAllPosts() | orderBy :'-votes' "> 
     <div ng-model="topic1" ng-repeat=" post in postCtrl.getAllPosts() | filter:{topicId:'1'} | orderBy :'-votes'"> "> 
      <div ng-model="topic2" ng-repeat=" post in postCtrl.getAllPosts() | filter:{topicId:'2'} | orderBy :'-votes'"> "> 
       <div ng-model="topic3" ng-repeat=" post in postCtrl.getAllPosts() | filter:{topicId:'3'} | orderBy :'-votes'"> 

そして、これらは私のボタンです:

<a class="btn-flat topic" >All</a> 
<a class="btn-flat topic">Inspire</a> 
<a class="btn-flat topic">Show Off</a> 
<a class="btn-flat topic">Share</a> 

タブをクリックすると、各フィルタNGリピートシナリオのみトリガーされるように、私はそれを設定するにはどうすればよいです。これどうやってするの?

+0

ng-clickを使用して変数値を変更してリストを更新することはできますか? – Patrick

+0

ちょうどそれを試み、それは働いています。 – TYPOI

答えて

0
<a class="btn-flat topic" ng-click="postCtrl.topicId = undefined">All</a> 
    <a class="btn-flat topic" ng-click="postCtrl.topicId = 1">Inspire</a> 
    <a class="btn-flat topic" ng-click="postCtrl.topicId = 2">Show Off</a> 
    <a class="btn-flat topic" ng-click="postCtrl.topicId = 3">Share</a> 

<div ng-model="topic0" ng-repeat="post in postCtrl.getAllPosts() | orderBy :'-votes' | filter: { topicId: postCtrl.topicId}"> 
関連する問題