本文介绍了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,的

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

过滤器:因为它是从ng-options而独特的过滤器不显示angular.js

选择部分:

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

NG-重复部分

< TR数据-NG-重复=DAT数据|过滤器:countryModel数据-NG-风格=SET_COLOR(DAT)>

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

07-22 19:19
查看更多