我有ng-switch="field.type"
一个包含ng-switch-when
但我想在它不仅仅是一个时打开开关的元素field.type
。
我会假设类似的东西ng-switch-when="type1 || type2"
会起作用,但事实并非如此。
这样做的正确方法是什么?
我有ng-switch="field.type"
一个包含ng-switch-when
但我想在它不仅仅是一个时打开开关的元素field.type
。
我会假设类似的东西ng-switch-when="type1 || type2"
会起作用,但事实并非如此。
这样做的正确方法是什么?
您可以通过为每个值复制相同的 ng-switch-when 元素(即具有相同内容/innerHTML 的元素)来解决它。
像这样:
<div ng-controller="mainCtrl">
<div ng-switch="expression">
<div ng-switch-when="matchvalue1">Item 1</div>
<div ng-switch-when="matchvalue2">Item 1</div>
<div ng-switch-when="matchvalue3">Item 3</div>
<div ng-switch-default>default</div>
</div>
</div>