I'm trying to do a filter, which will group my collection items by the determined field (like groupBy filter from angular-filter library)
app.filter('groupBySortedField', function() {
return function(collection, property) {
var result = {};
angular.forEach(collection, function(item) {
var prop = item[property];
if (!result[prop]) {
result[prop] = [];
}
result[prop].push(item);
});
return result;
};
});
It's works well, but i got a lot of errors in console:
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached.
Look at the example with opened console http://plnkr.co/edit/HFlB7VTMCe2GnM3SUirs?p=preview
How to fix it?