//过滤重复数据
.filter('unique', function() {
return function(collection, keyname) {
var output = [],
keys = [];
angular.forEach(collection, function(item) {
var key = item[keyname];
if (keys.indexOf(key) === -1) {
keys.push(key);
output.push(item);
}
});
return output;
};
})
//精确查找
.filter('accurateQuery', function() {
return function(collection, keyname, comparename) {
var output = [],
keys = [];
angular.forEach(collection, function(item) {
var key = item[keyname];
if (comparename===key) {
keys.push(key);
output.push(item);
}
});
return output;
};
})