我在表格中有以下数据:
data = [
{id: 1, name: 'Manchester United', type: 'Soccer', featured: true, country: 'England'},
{id: 2, name: 'Manchester City', type: 'Soccer', featured: false, country: 'England'},
{id: 3, name: 'Dallas Mavericks', type: 'Basketball', featured: true, country: 'USA'},
{id: 4, name: 'Indian Cricket Team', type: 'Cricket', featured: true, country: 'India'},
{id: 5, name: 'Australian Cricket Team', type: 'Cricket', featured: false, country: 'Australia'},
{id: 6, name: 'Los Angeles Lakers', type: 'Basketball', featured: true, country: 'USA'},
{id: 7, name: 'Los Angeles Clippers', type: 'Basketball', featured: false, country: 'USA'}
];
我想在国家/地区添加一个下拉框。选择国家/地区应过滤表格,仅显示该国家/地区的体育赛事。
问题在于我无法在下拉列表中显示唯一的国家/地区。
请帮助......提前致谢。
答案 0 :(得分:2)
我修改了你的plnkr http://plnkr.co/edit/60GO0zhSGoEUm7tu6mbc?p=preview
过滤:来自ng-options and unique filter not displaying angular.js
选择部分:
<select data-ng-model="countryModel" ng-options="dd.country as dd.country for dd in data | unique:'country'">
ng-repeat部分
<tr data-ng-repeat="dat in data | filter: countryModel" data-ng-style="set_color(dat)">