我正在学习angularjs,并且还在为选择而苦苦挣扎。我知道这个问题已经得到解答,但是想分享更多的代码。Angular JS多选框过滤器无法正常工作?
在我的测试,我有两个列表框:比赛名称和比赛城市
比赛城市应该是唯一的
当我选择比赛的名称会显示相应的比赛名单中它的到来正确只 当我seclect城市选择框,它不会填充任何事情
app.controller('MainCtrl', function($scope) {
$scope.tournaments = [
{ id: 1, name: 'Banglore Cup', city:'Banglore' },
{ id: 2, name: 'Banglore Cup1', city:'Mumbai' },
{ id: 3, name: 'Banglore Cup2', city:'Banglore' },
{ id: 4, name: 'Mumbai Cup1', city:'Mumbai' },
{ id: 5, name: 'Mumbai Cup2', city:'Banglore' }
];
});
<div class="row">
<div class="col s4 input-field ">
<select class="browser-default" name="show-filter" ng-model="tournamentFilter.id" ng-options="eachTournament.id as eachTournament.name for eachTournament in tournaments">
<option value="" selected> All</option>
</select>
</div>
<div class="col s4 input-field ">
<select class="browser-default" name="show-filter" ng-model="tournamentFilter.city" ng-options="eachTournament.city as eachTournament.city for eachTournament in tournaments| unique:'city'">
<option value="" selected> All</option>
</select>
</div>
</div>
</div>
<div class="col s12">
<table class="list_tournament">
<tbody ng-repeat="eachTournament in tournaments | filter:{id:tournamentFilter.id||undefined} | orderBy:'name'">
<tr class="row nomargin">
<td class="col s4 m3 tournament_list_location">
<a href="#/viewtournament/{{eachTournament.id}}">{{eachTournament.name}}</a>
</td>
<td class="tournament_list_location col s12 m3">
{{eachTournament.city}}
</td>
</tr>
</tbody>
</table>
</div>
你能帮我获取数据
请加小提琴或plunker –
@cherry HTTP:/ /plnkr.co/edit/I4iCnEoRBDF8OWaX9vry?p=preview –
@SaEChowdary谢谢你我其实我不知道如何创建小提琴或plnkr.please帮我回答我的问题 –