I have my ng-repeat returning arrays like the ones below:
[{"day":"10","title":"day","summary":"summary","description":"ok","_id":"53f25185bffedb83d8348b22"}]
[{"day":"3","title":"day","summary":"summary","description":"ok","_id":"53f25185bffedb83d8348b22"}]
I'd like to create a filter to combine the arrays into one array so that I can use an orderBy | 'day'.
[
{"day":"10","title":"day","summary":"summary","description":"ok","_id":"53f25185bffedb83d8348b22"},
{"day":"3","title":"day","summary":"summary","description":"ok","_id":"53f25185bffedb83d8348b22"
}]
I have a filter used to filter my overall object, but the logic here is much simpler, I'm not sure how to tweak the filter I have to concatenate these objects.
angular.module('hcApp')
.filter('combine', function() {
return function(items) {
var temp = [];
var result = temp.concat.apply(temp,items.map(function(itm){
return temp.concat.apply(temp, Object(itm).map(function(key){
return itm.year[key];
}));
}));
return result;
};
});