就像我们在C#中一样(具有相同输出的多个值)
switch (CommandId)
{
case 1:
case 2:
.
.
.
{
return "test";
}
}
我想在angularjs中有2个或更多个案例具有相同的输出
<div ng-switch="ctrl.Step">
<button class="md-raised md-primary" ng-switch-when="1" ng-click="ctrl.save()">
Save
</button>
<button class="md-raised md-primary" ng-switch-when="2" ng-click="ctrl.save()">
Save
</button>
</div>
这种代码的语法是什么?
您可以使用ng-switch-when-separator进行操作,请查看doc。
<div ng-switch="ctrl.Step">
<button class="md-raised md-primary" ng-switch-when="1|2" ng-switch-when-separator="|" ng-click="ctrl.save()">
Save
</button>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句