angularjs:多个值在NG-开关时 [英] angularjs: multiple values in a ng-switch-when

查看:118
本文介绍了angularjs:多个值在NG-开关时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下ngSwitch:

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 to options wrong and correct. I have tried (as you can see) to use the pipe |, but that doesn't work. Any suggestions ?

推荐答案

您不能有一个多个条件NG-开关时

一个替代方案是使用 NG-如果,但在错误处理的情况下,我preFER对控制器的范围填充的错误变量,并使用 NG-秀=误差

One alternative is to use an ng-if, but in the case of error handling, I prefer to populate an error variable on the scope in the controller, and use ng-show=error.

这篇关于angularjs:多个值在NG-开关时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆