AngularJS:如何获得NG选项的唯一值? [英] AngularJS : How to get the unique values in ng-option?

查看:122
本文介绍了AngularJS:如何获得NG选项的唯一值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个表中的下列数据:

I have the following data in a table:

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'}
];

我想补充一个下拉与各国框。选择一个国家应该过滤表,从该国仅显示运动。

I want to add a drop down box with countries. Selecting a country should filter the table to show only sports from that country.

问题是,我无法展现出独特的国家在下拉列表中。

The problem is that I am unable to show the unique countries in the dropdown.

请帮助...在此先感谢。

Kindly Help...Thanks in advance.

推荐答案

我修改您的plnkr,的 http://plnkr.co/edit/60GO0zhSGoEUm7tu6mbc?p=$p$pview

I modified your plnkr, http://plnkr.co/edit/60GO0zhSGoEUm7tu6mbc?p=preview

过滤器:因为它是从<一个href=\"http://stackoverflow.com/questions/18381944/ng-options-and-unique-filter-not-displaying-angular-js\">ng-options而独特的过滤器不显示angular.js

选择部分:

&LT;选择数据-NG-模式=countryModelNG选项=dd.country作为dd.country在数据DD |独特:'国家'&GT;

NG-重复部分

&LT; TR数据-NG-重复=DAT数据|过滤器:countryModel数据-NG-风格=SET_COLOR(DAT)&GT;

这篇关于AngularJS:如何获得NG选项的唯一值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆