I have the following ngSwitch:
<p ng-switch="status"> <span ng-switch-when="wrong|incorrect"> Wrong </span> <span ng-switch-default> Correct </span> </p>
As you can see, I have the text Wrong
for two options wrong
and correct
. I have tried (as you can see) to use the pipe |
, but that doesn't work. Any suggestions ?
Definition and UsageThe ng-switch directive lets you hide/show HTML elements depending on an expression. Child elements with the ng-switch-when directive will be displayed if it gets a match, otherwise the element, and its children will be removed.
The ngSwitch directive is used to conditionally swap DOM structure on your template based on a scope expression.
The [ngSwitch] directive on a container specifies an expression to match against. The expressions to match are provided by ngSwitchCase directives on views within the container. Every view that matches is rendered. If there are no matches, a view with the ngSwitchDefault directive is rendered.
For angular >=v1.5.10,
You can do it by adding ng-switch-when-separator="|"
to ng-switch-when
node. see example in documentation.
<span ng-switch-when="wrong|incorrect" ng-switch-when-separator="|">
see discussion here https://github.com/angular/angular.js/issues/3410 Note, based on my experience it doesn't work with numbers...yet?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With