{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>
.......
这个和 angular 无关,还是先看看 javascript 吧。
ng-if后面就是正常的js语句,如果你的意图就是比较code是否等于
2||3
,那这样写o。k如果你的意图是判断code或者等于2,或者等于3,那就是
当然,code必须首先在angular的作用域里面。
{true:THIS, false:THAT}[CONDITION]
<p ng-repeater="item in items">
</p>
方法二:
<p ng-repeater="item in items">