In my web application built with AngularJS, I am dynamically creating objects. The goal is to allow users to load new events by clicking a button. To achieve this functionality, I need to determine the date of the last event loaded so that I can fetch the next ones.
Below is the code snippet responsible for generating the JSON object:
services.getEvents().then(function(data){
$scope.events = data.data;
});
Here's a glimpse at the corresponding HTML:
<li ng-repeat="event in events | orderBy:'-event_date' ">
<span>{{event.event_date}},{{event.event_name}}, {{event.event_venue}}, {{event.event_description}} </span>
</li>
Take a look at an example event from the list:
{
"event_id":"1",
"event_name":"Event 1",
"event_date":"2014-09-26 00:00:00",
"event_venue":"Limerick",
"event_description":"stuff"
}
My question is - how can I extract the latest date from these events in order to send it back to the API? Am I approaching this problem incorrectly?
Furthermore, I see this as an opportunity to enhance my understanding of AngularJS.