Separate Concerns, Reduce Mocking
We want the list of tasks to appear in the ascending order of year, month, day, and name. That calls for a sort operation, but where to put that? We need to make a careful decision about this—keep modularity and the single responsibility principle in mind.
Find the Right Place
AngularJS makes it very easy to sort data, right in the HTML page. Here’s one possible solution that could go into the HTML page we’ll design eventually:
|||<tr ng-repeat="task in controller.tasks | orderBy: year">...</tr>|
That’s sleek, or…is it sick?
At first sight that looks sleek—concise, declarative, elegant. But then, the sorting logic would be in the HTML page. We want to sort based on a particular precedence now and may want to change ...