I have a JSON object representing calendar dates. They are added via CMS, and I would like to be able to filter them by date. My circuit setup made it harder than I thought. Is it possible to order the day value in this JSON object, or is there a filter bypass?
Here is my JSON object:
{ "_id" : ObjectId("53f252537d343a9ad862866c"), "year" : { "December" : [], "November" : [], "October" : [], "September" : [], "August" : [], "July" : [ { "day" : "21", "title" : "Event Title", "summary" : "Event Summary", "description" : "oEvent Description", "_id" : ObjectId("53f252537d343a9ad862866d") } ], "June" : [], "May" : [], "April" : [], "March" : [], "February" : [], "January" : [] }, "__v" : 0 }
Here is my view, which already uses a custom filter to filter by month. OrderBy does not work, but I left it as a placeholder to show where I would like to set the functionality.
<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"> <div ng-repeat="item in cal | orderBy: 'key.day' "> <a href="/events/{{item.day}}"> <article class="eventslist"> <div class="numberedDate"> <h3>{{item.day}}</h3> </div> <div class="calInfo"> <h5>{{item.title}}</h5> <p>{{item.summary}} <a>more</a></p> </div> </article> </div> </div> </div> </div> </div>
json angularjs angular-filters angularjs-orderby
byrdr
source share