I'm working with AngularJS and trying to create a filter to search properties.
I've got a select box like this:
<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>
This is the unique function:
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;
}; });
How can I get filtered.length
to work?
Here's my JSFiddle