[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];
原文地址:https://www.cnblogs.com/Answer1215/p/10187089.html