0
<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>

If I have more than 0 item, text getting 'Remove items', right. But I want, if I have one item, text change to 'Remove item' So,

item == 1 == remove item

item > 1 == remove items

How can I setup this?

1 Answer 1

1

use like this,

<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>

if (ItemIndex.ItemCount == 1) is true then prints Remove item, else prints Remove items.

OR you can use ng-show, ng-hide or 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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.