search

Home  >  Q&A  >  body text

angular.js - usage of angular ng-switch

The code is as follows:

<p ng-switch="vm.status">
    <p ng-switch-when="1">
        <!--code-->
    </p>
    <p ng-switch-when="2">
        <!--code-->
    </p>
    <p ng-switch-when="3">
        <!--code-->
    </p>
    <p ng-switch-when="4">
        <!--code-->
    </p>
</p>

When the values ​​​​are 1 and 2, the output content is the same. Can it be merged at this time, such as this:

<p ng-switch="vm.status">
    <!--1和2时,合并在一起输出-->
    <p ng-switch-when="1||2">
        <!--code-->
    </p>
    <p ng-switch-when="3">
        <!--code-->
    </p>
    <p ng-switch-when="4">
        <!--code-->
    </p>
</p>

In js, if you don’t write break in switch, you can execute through it, but angular doesn’t know how to do it, and the tutorial doesn’t mention this either

某草草某草草2825 days ago728

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:55:38

    ng-switch-when cannot have multiple values, but it can be modified,

    http://stackoverflow.com/questions/22610543/angularjs-multiple-values-...

    reply
    0
  • Cancelreply