ngSwitch和NGPluble-Angular的区别是什么

ngSwitch和NGPluble-Angular的区别是什么,angular,Angular,我浏览了Angular文档,找不到它们之间的区别 在本例中,我也在它们之间进行了切换: 并且得到了相同的结果ngSwitch根据布尔表达式值有条件地添加/删除DOM元素 ngPlural有条件地添加/删除DOM子树取决于数值ngSwitch有条件地添加/删除DOM元素取决于任何值字符串、数字、布尔值 ngSwitch:有吗 ngPlural有条件地添加/删除DOM子树仅取决于数值 复数:数字 Html文件 <p> I have {{count1}} items, but I cou

我浏览了Angular文档,找不到它们之间的区别 在本例中,我也在它们之间进行了切换:
并且得到了相同的结果

ngSwitch根据布尔表达式值有条件地添加/删除DOM元素


ngPlural有条件地添加/删除DOM子树取决于数值

ngSwitch有条件地添加/删除DOM元素取决于任何值字符串、数字、布尔值 ngSwitch:有吗

ngPlural有条件地添加/删除DOM子树仅取决于数值 复数:数字

Html文件

<p>
 I have {{count1}} items, but I could also say 

 <span [ngSwitch]="count1">
 <ng-template ngSwitchCase="zero">there are no items.</ng-template>
 <ng-template ngSwitchCase="one">there is one item.</ng-template>
 <ng-template ngSwitchCase="2">there are four items.</ng-template>
 <ng-template ngSwitchCase="many">there are many items.</ng-template>
 <ng-template ngSwitchCase="other">there are some items.</ng-template>
 </span>
</p>

<p>
 I have {{count}} items, but I could also say 

 <span [ngPlural]="count">
 <ng-template ngPluralCase="zero">there are no items.</ng-template>
 <ng-template ngPluralCase="one">there is one item.</ng-template>
 <ng-template ngPluralCase="2">there are four items.</ng-template>
 <ng-template ngPluralCase="many">there are many items.</ng-template>
 <ng-template ngPluralCase="other">there are some items.</ng-template>
 </span>
</p>

[ngPluralCase]创建一个视图,根据CLDR规则,当给定表达式与复数表达式匹配时,该视图将从父ngPluralCase中添加/删除


参考本网站

布尔值表示表达式,表达式总是返回true或false,这是开关大小写语句。那么为什么要使用NGPLUMAL?那么difference@OmarHasan请仔细阅读CLDR规则,然后您就会明白。根据我的理解,“复数”在多语言项目中很有用。
export class AppComponent {
  count = "zero" // ngPlural when I give string values it goes to default statement
  count1 = "one" // ngSwitch works here perfectly
}