I managed to create a small sample that works out of the box and can reproduce the issue. It's a filter that removes randomly 2 elements from an array:
<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<meta charset="utf-8" />
<script src="https://code.angularjs.org/1.6.5/angular.js"></script>
<script>
angular.module('myApp', [])
.filter('random', function() {
return function(input) {
var a = Math.floor(Math.random()*input.length);
var b = Math.floor(Math.random()*input.length);
return input.filter(function(element, i){
if (i !== a && i !== b){
return element;
}
});
};
})
.controller('Controlleur', function($scope) {
$scope.contacts = [
{"name": "donatello", "tel": 12456},
{"name": "michaelangelo", "tel": 12456},
{"name": "leonardo", "tel": 12456},
{"name": "raphael", "tel": 12456},
{"name": "robert", "tel": 12456},
]
});
</script>
</head>
<body ng-controller="Controlleur">
<ul>
<li ng-repeat="contact in contacts|random track by contact.name ">
<strong>{{contact.name}}</strong>: {{contact.tel}}
</li>
</ul>
</body>
</html>
Copy/paste that in a file, load the file in a browser, and open the console. If you hit F5 a few number of times, you'll see the filter works but you'll randomly get:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"fn: regularInterceptedExpression","newVal":21,"oldVal":18},{"msg":"fn: regularInterceptedExpression","newVal":"raphael"},{"msg":"fn: regularInterceptedExpression","newVal":"12456"},{"msg":"fn: regularInterceptedExpression","newVal":"robert"},{"msg":"fn: regularInterceptedExpression","newVal":"12456"}],
...
The problem is that it usually means $digest is triggered too many times in a row. However, I don't update the scope explicitly anywhere. I'm merely creating a new array in a filter, with so apparent side effect.