AngularJS:ng-switch-when 与 OR [英] AngularJS: ng-switch-when with an OR
本文介绍了AngularJS:ng-switch-when 与 OR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 ng-switch-when 中可以有 OR 吗?
<div ng-switch-when="val1 **OR** val2">超
如果没有,如何实现上述功能?
谢谢:)
解决方案
ngswitch
只允许你比较单个条件.
我想测试多个条件,你可以使用 ng-if
和 1.1.5 版
需要注意的是,使用 ng-if
和 ng-switch
从DOM结构中移除元素,与显示和隐藏相对.
当您遍历 DOM 以查找元素时,这很重要.
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 :)
解决方案
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
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.
这篇关于AngularJS:ng-switch-when 与 OR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文