Heim > Fragen und Antworten > Hauptteil
怪我咯2017-05-15 17:02:53
ng-if后面就是正常的js语句,如果你的意图就是比较code是否等于2||3
,那这样写o。k
如果你的意图是判断code或者等于2,或者等于3,那就是
code === 2 || code === 3
当然,code必须首先在angular的作用域里面。
过去多啦不再A梦2017-05-15 17:02:53
{true:THIS, false:THAT}[CONDITION]
<p ng-repeater="item in items">
<p>{{item.description}}</p>
<p>{{ {true:'available', false:'oh no, you don't have it'}[isExists(item)] }}</p>
</p>
方法二:
<p ng-repeater="item in items">
<p>{{item.description}}</p>
<p ng-switch on="isExists(item)">
<span ng-switch-when="true">Available</span>
<span ng-switch-default>oh no, you don't have it</span>
</p>
</p>
方法三:
<p ng-repeater="item in items">
<p>{{item.description}}</p>
<p ng-show="isExists(item)">available</p>
<p ng-show="!isExists(item)">oh no, you don't have it</p>
</p>