Webnet Webnet - 7 months ago 117
AngularJS Question

Angular expression if array contains

I'm trying to add a class to an element if a

has not been selected for approval using expressions.

<li class="approvalUnit" ng-repeat="jobSet in dashboard.currentWork" ng-class="{-1:'approved'}[selectedForApproval.indexOf(jobSet)]">

This isn't exactly a fool proof method. Any suggestions on how I should do this?


You can accomplish this with a slightly different syntax:

ng-class="{'approved': selectedForApproval.indexOf(jobSet) === -1}"