AngularJS: ng-switch-when with an OR

Pavel picture Pavel · Jan 24, 2013 · Viewed 34.1k times · Source

Is it possible to have an OR in ng-switch-when?

<div ng-repeat="w in windows" ng-show="visibleWindowId == w.id" ng-switch="w.type">
    <div ng-switch-when="val1 **OR** val2">
        sup
    </div>
</div>

If not, how could the above be accomplished?

Thanks :)

Answer

Malkus picture Malkus · May 24, 2013

ngswitch only allows you to compare a single condition.

I you are looking to test multiple conditions you can use ng-if available with version 1.1.5

Reference

It is important to note that using ng-if and ng-switch remove the element from the DOM structure, opposed to show and hide.

This is important when you traverse the DOM to find elements.