From 6ba8b26687ffde873e08f4f40409894450246510 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Betancourt Date: Sat, 6 Sep 2014 19:51:00 -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/count-by.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/_filter/collection/count-by.js b/src/_filter/collection/count-by.js index 0be73e0..19085aa 100644 --- a/src/_filter/collection/count-by.js +++ b/src/_filter/collection/count-by.js @@ -9,11 +9,10 @@ angular.module('a8m.count-by', []) - .filter('countBy', [ '$parse', function ( $parse ) { + .filter('countBy', function () { return function (collection, property) { var result = {}, - get = $parse(property), prop; collection = (isObject(collection)) ? toArray(collection) : collection; @@ -23,7 +22,7 @@ angular.module('a8m.count-by', []) } collection.forEach( function( elm ) { - prop = get(elm); + prop = elm[property]; if(!result[prop]) { result[prop] = 0; @@ -34,4 +33,4 @@ angular.module('a8m.count-by', []) return result; } - }]); + });