填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

NgPlural

根據數字值新增/刪除 DOM 子樹。為支援複數詞量身訂製。

Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.

檢視"說明"...

Exported from

選擇器

屬性

屬性說明
@Input()
ngPlural: number
只寫

說明

顯示與開關表示式值匹配的 DOM 子樹,否則顯示與開關表示式的複數類別匹配的 DOM 子樹。

Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees that match the switch expression's pluralization category.

要使用此指令,必須提供一個容器元素,該元素將 [ngPlural] 屬性設定為 switch 表示式。 [ngPluralCase] 內部元素將根據其表示式顯示:

To use this directive you must provide a container element that sets the [ngPlural] attribute to a switch expression. Inner elements with a [ngPluralCase] will display based on their expression:

  • 如果 [ngPluralCase] 設定為以 = 開頭的值,則僅在該值與 switch 表示式完全匹配時才會顯示,

    if [ngPluralCase] is set to a value starting with =, it will only display if the value matches the switch expression exactly,

  • 否則,該檢視將被視為“類別匹配”,並且僅在未找到精確值匹配且該值對映到已定義語言環境的類別時才會顯示。

    otherwise, the view will be treated as a "category match", and will only display if exact value matches aren't found and the value maps to its category for the defined locale.

參見 http://cldr.unicode.org/index/cldr-spec/plural-rules

See http://cldr.unicode.org/index/cldr-spec/plural-rules

      
      <some-element [ngPlural]="value">
  <ng-template ngPluralCase="=0">there is nothing</ng-template>
  <ng-template ngPluralCase="=1">there is one</ng-template>
  <ng-template ngPluralCase="few">there are a few</ng-template>
</some-element>
    

方法

      
      addCase(value: string, switchView: SwitchView): void
    
引數
value string
switchView SwitchView
返回值

void