【发布时间】:2015-12-22 19:57:32
【问题描述】:
我正在使用 AngularJS 并尝试创建一个过滤器来搜索属性。
我有一个这样的选择框:
<select
class="selectBox"
multiple="multiple"
ng-model="selectedSubArea"
ng-options="property.SubArea as (property.SubArea + ' ('+ filtered.length +')') for property in filtered = (properties | unique:'SubArea') | orderBy:'SubArea'">
</select>
这是独特的功能:
myApp.filter('unique', function() {
return function(input, key) {
var unique = {};
var uniqueList = [];
for(var i = 0; i < input.length; i++){
if(typeof unique[input[i][key]] == "undefined"){
unique[input[i][key]] = "";
uniqueList.push(input[i]);
}
}
return uniqueList;
}; });
如何让filtered.length 工作?
这是我的JSFiddle
【问题讨论】:
标签: angularjs ng-repeat ng-options