From dc06134a40682de9965affb0fd366125109053cd Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Betancourt Date: Sat, 6 Sep 2014 19:55:23 -0500 Subject: [PATCH] Added support for object key with spaces This fix adds support to filter JSON data that contains keys names with spaces, and avoids runtime errors. as $parse is needed no more, i removed it. --- src/_filter/collection/unique.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/_filter/collection/unique.js b/src/_filter/collection/unique.js index 93bf5c4..26e7312 100644 --- a/src/_filter/collection/unique.js +++ b/src/_filter/collection/unique.js @@ -11,11 +11,11 @@ angular.module('a8m.unique', []) .filter({ - unique: ['$parse', uniqFilter], - uniq: ['$parse', uniqFilter] + unique: uniqFilter, + uniq: uniqFilter }); -function uniqFilter($parse) { +function uniqFilter() { return function (collection, property) { collection = (isObject(collection)) ? toArray(collection) : collection; @@ -25,8 +25,7 @@ function uniqFilter($parse) { } //store all unique identifiers - var uniqueItems = [], - get = $parse(property); + var uniqueItems = []; return (isUndefined(property)) ? //if it's kind of primitive array @@ -35,7 +34,7 @@ function uniqFilter($parse) { }) : //else compare with equals collection.filter(function (elm) { - var prop = get(elm); + var prop = elm[property]; if(some(uniqueItems, prop)) { return false; }