I have a complex array which has objects inside of parent objects. I've already extracted the objects I want to work with through ng-repeat and am returning them. I'd like to be able to put all of these objects into an array using an angular forEach. I'm not quite sure how to go about doing it.
Here are the objects I'm returning:
{"day":"21","title":"ok","summary":"ok","description":"ok","_id":"53ee9f0fc6aed109c6d33cfd"}
{"day":"2","title":"ok","summary":"ok","description":"ok","_id":"53ee9f038782309c6d892"}
{"day":"27","title":"ok","summary":"ok","description":"ok","_id":"533240fc6ae32433chd"}
Here is my view: The objects above are represented by 'items' in the ng-repeat.
<div class="calDynamic" data-ng-repeat="n in [] | range:100">
<div ng-repeat="cal in calendar[n].year | filterKey:month">
<div ng-if="cal != '' ">
<div class="calendar">
<p>{{cal}}</p>
<div ng-repeat="items in cal ">
<a href="/events/{{items.day}}">
<article class="eventslist">
<div class="numberedDate">
<h3>{{items.day}}</h3>
</div>
<div class="calInfo">
<h5>{{items.title}}</h5>
<p>{{items.summary}} <a>more</a></p>
</div>
</article>
</div><!-- ng-repeat val,key -->
</div><!-- calendar -->
</div><!-- ng-if cal -->
</div><!-- ng-repeat cal -->
</div><!-- calDynamic -->
How would I go about using a foreach loop like the one below to store those returned objects into an array so that I could use the filter method on it?
var arr = [];
angular.forEach(items, function (item) {
arr.push(item);
});
ng-repeat="items in cal | insertdayfilterhere"
– Malkus Aug 19 '14 at 16:58|
to separate them if you wanted to add to the parentng-repeat
"cal in calendar[n].year | filterKey:month | insertdayfilterhere">
– Malkus Aug 19 '14 at 16:59