Creating a test filter that returns constant data was my goal.
mainApp.filter('dateParser', function () {
return function (param) {
return [{id:1,day:'23.07.17'},{id:2,day:'22.07.17'}];
};
});
However, when I try to use it like this:
<td ng-repeat="crrDay in studentOne.daysList|dateParser">
{{day.currentVal}}
</td>
I am able to retrieve the desired data but an error appears in the console:
Error: $rootScope:infdig
Infinite $digest Loop
Could you explain why this is happening?
UPDATE Full filter code:
mainApp.filter('dateParser', function () {
console.log(this);
return function (param) {
var parse, sorted, result = [], parsedArray = [];
for (var i = 0; i < param.length; i++) {
parse = param[i].day.split('.');
parsedArray[i] = {
'id': param[i].id,
'day': parse[0],
'month': parse[1],
'year': parse[2]
};
}
sorted = _.sortBy(parsedArray, ['year', 'month', 'day']);
for (i = 0; i < sorted.length; i++) {
result[i] = {
id:sorted[i].id,
day: sorted[i].day + '.' + sorted[i].month + '.' + sorted[i].year
};
}
return result;
};
});