Webnet Webnet - 1 year ago 240
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?

Answer Source

You can accomplish this with a slightly different syntax:

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download