Given an array of “visits” [{ date:DATE, summary:TEXT }, { date:DATE, summary:TEXT }, …]
, if I need to show the last visit, where would I do the calculation:
- In the controller and add the calculated value to the $scope -
<div>{{lastVisit}}</div> - Using a $scope method -
<div>{{getLastVisit()}}</div> - In the view (this definitely doesn’t feel right) -
<div>{{visits[visits.length-1]}}</div>
I am avoiding for now the question whether the model should be manipulated inside the controller or in its own service.
visitsbeing maintained within the controller?