You should not overload templates with complex logic, this is bad practice. Remember to always keep this in mind!
A better approach would be to extract this logic into the reusable function on $rootScope :
.run(function ($rootScope) { $rootScope.inArray = function (item, array) { return (-1 !== array.indexOf(item)); }; })
Then use it in the template:
<li ng-class="{approved: inArray(jobSet, selectedForApproval)}"></li>
I think everyone will agree that this example is much more readable and easy to maintain.
Slava Fomin II Mar 07 '16 at 18:33 2016-03-07 18:33
source share