[Angular] ngPlural

The usecase is very simple:

   <div [ngPlural]="items.length">
      <ng-template ngPluralCase="=0">There is no item</ng-template>
      <ng-template ngPluralCase="=1">There is one item</ng-template>
      <ng-template ngPluralCase="other">There is {{items.length}} items</ng-template>
   </div>

'=0' & '=1' are exactly match, 'other' are category match for the rest of numbers, you have to use 'other', this is the rule.

Typescript:

items: Number[] = [1];

 

posted @ 2018-12-27 20:16  Zhentiw  阅读(376)  评论(0编辑  收藏  举报