Hi Johnny,
The only way to do this without caching is prepare the data in the controller, before rendering it.
The reason it keeps on digesting is because every time you return a new set of array’s, those are not known to angular, so angular goes forth and tags it with an $id, which, in turn causes an digest wich.. (restart reading this sentence!)
Ok, now you have broken out of the infinitive reading loop of above ;) I will show you a more elegant, yet unusable option. This is one of the thing that ES6 shines at.
this only works in FF or in chrome if you have set the “Enable Experimental JavaScript” flag.
app.filter('partition', function() {
var mp = new Map();
var filter = function(arr, size,killCache) {
if (killCache) {mp.clear();}
if (!arr) { return; }
if (mp.has(size) && mp.get(size).has(arr)) {
return mp.get(size).get(arr);
}
var newArr = [];
for (var i=0; i<arr.length; i+=size) {
newArr.push(arr.slice(i, i+size));
}
if (!mp.has(size)) {
// new size item, create it!
mp.set(size,new WeakMap());
}
mp.get(size).set(arr,newArr);
return newArr;
};
return filter;
});