angularjsangularjs-1.5angularjs-ng-if

Trying to shorten check conditions using or in ng-if directive. Comparing series value with multiple times as there are many values to check in or


<img src="img/temp.png" class="img-responsive" ng-if="series === 'Temperature' || series === 'T' || series === 'Temperature-138828'">

I tried like this, but it didn't work:

<img src="img/temp.png" class="img-responsive" ng-if="series === ('Temperature' || 'T' || 'Temperature-138828')">

Is there a way to shorten this <img> tag (such as to compare series with multiple values or something else?). I haven't used angularjs a lot, so any advice would be appreciated.


Solution

  • Try like this:

    <img src="img/temp.png" class="img-responsive" ng-if="['Temperature', 'T', 'Temperature-138828'].indexOf(series) > -1">