Angular.js:过滤NG重复按缺席阵列 [英] Angular.js: filter ng-repeat by absence in array
本文介绍了Angular.js:过滤NG重复按缺席阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要,这样只有产品这不是在alreadyAddedValues出现()阵列将被显示来过滤以ng重复项目:
I need to filter items in ng-repeat so that only the items which not appear in alreadyAddedValues() array will be shown:
<ul class="dropdown-menu">
<li ng-repeat="v in values() | filter: { ????? } ">{{value.name}}</li>
</ul>
$scope.values() = function(){
................
}
$scope.alreadyAddedValues() = function()
{
//returns an array
}
已经增值的搜索应该由 value.shortName
推荐答案
可以,例如,使用自定义函数来完成筛选:
You can, for example, use a custom function to do the filtering:
<li ng-repeat="v in values() | filter:filterAlreadyAdded ">{{value.name}}</li>
在控制器:
$scope.filterAlreadyAdded = function(item) {
// filter logic here...
// return false if item already added, true otherwise
};
的jsfiddle : http://jsfiddle.net/bmleite/5VbCJ/
这篇关于Angular.js:过滤NG重复按缺席阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文