AngularJS NG选项排除特定对象 [英] AngularJS ng-options to exclude specific object
本文介绍了AngularJS NG选项排除特定对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的角度NG选项来显示几个选项作为当前类父类的选择,基本上这些选项包含所有现有的类别,而我需要排除NG选项当前类别,这非常有意义,因为一个类别不能成为自己的父类。那么,如何做呢?目前,我有以下code:
< TR NG重复=,在allCategories类别>
百分位NG绑定=category.name>< /第i
<第i个
<选择NG选项=在allCategories为everyCategory everyCategory.name>
<期权价值=>选择父类< /选项>
< /选择>
< /第i
< / TR>
解决方案
您应该使用的过滤器。
<选择NG选项=在allCategories everyCategory.name为everyCategory |过滤器:{名称:'! + category.name}> ...< /选择>
I'm using angular ng-options to show a with several options as the choices of parent category of the current category, basically these options contain all the existing categories, and I need to exclude the current category from ng-options, which quite make sense because a category cannot be the parent category of itself. So how do I do that? Currently I have the following code:
<tr ng-repeat="category in allCategories">
<th ng-bind="category.name"></th>
<th>
<select ng-options="everyCategory.name for everyCategory in allCategories">
<option value="">Select parent category</option>
</select>
</th>
</tr>
解决方案
You should use filter.
<select ng-options="everyCategory.name for everyCategory in allCategories | filter: { name: '!' + category.name }">...</select>
这篇关于AngularJS NG选项排除特定对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文