<span ng-if="ItemIndex.ItemCount>0"><a href="#" ng-click="deleteItem(ItemIndex)"
class="underlined-text-button"><i
class="glyphicon glyphicon-remove"></i> Remove items</a>
</span>
如果我的项目超过0,则会收到“删除项目”的文字。但我想,如果我有一个项目,文本更改为“删除项目” 所以,
item == 1 ==删除项目
item&gt; 1 ==删除项目
我该如何设置?
答案 0 :(得分:1)
像这样使用,
<span ng-if="ItemIndex.ItemCount>0">
<a href="#" ng-click="deleteItem(ItemIndex)"
class="underlined-text-button"><i
class="glyphicon glyphicon-remove"></i>
{{ (ItemIndex.ItemCount == 1) ? 'Remove item' : 'Remove items' }}
</a>
</span>
如果(ItemIndex.ItemCount == 1)
为真,则打印Remove item
,否则打印Remove items
。
或您可以使用ng-show
,ng-hide
或ng-if
,
<span ng-if="ItemIndex.ItemCount>0">
<a href="#" ng-click="deleteItem(ItemIndex)"
class="underlined-text-button"><i
class="glyphicon glyphicon-remove"></i>
<span ng-show="ItemIndex.ItemCount == 1"> Remove item </span>
<span ng-show="ItemIndex.ItemCount > 1"> Remove items </span>
</a>
</span>