Just ran into an infinite $digest loop when passing parameters to a filter defined on the $scope.
In HTML:
<ul id="albumListUL" class="fa-ul">
<li ng-repeat="album in GoogleList | myFilter:Field:Reverse track by album.id.$t">
<i class="fa-li fa fa-google-plus"></i>
<a href="#" id="{{album.gphoto$id.$t}}" class="g_album" alt="{{album.title.$t}}">
{{album.title.$t}} <span class="badge">{{album.gphoto$numphotos.$t}}</span>
</a>
</li>
</ul>
Controller:
.controller("AlbumListController", ['$scope', 'AlbumListService', function($scope, AlbumListService) {
$scope.Field = "published";
$scope.Reverse = true;
$scope.GoogleList = AlbumListService.GoogleList;
}])
Filter:
.filter('myFilter', function() {
return function(items, field, reverse) {
items.sort(function(a, b){
var aValue = a[field].$t.toLowerCase();
var bValue = b[field].$t.toLowerCase();
if(reverse)
{
return ((aValue > bValue) ? -1 : ((aValue < bValue) ? 1 : 0));
} else {
return ((aValue < bValue) ? -1 : ((aValue > bValue) ? 1 : 0));
}
});
return items;
};
})
If I run the code like this I will get the $digest loop error but the output will be sorted. If I instead of using $scope.Field and $scope.Reverse writes myFilter:'published':true it will work without the error. I have checked everything else, disabled all directives and other stuff that might interfere still the same issue.
Anyone have some good input on this?
AlbumListService.GoogleList?