{ "id": "api/common/NgPlural", "title": "NgPlural", "contents": "\n\n
\n
\n
\n \n API > @angular/common\n
\n \n
\n \n
\n

NgPlurallink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

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

\n\n

See more...

\n
\n \n \n \n \n\n

NgModulelink

\n\n\n\n \n
\n

Selectorslink

\n \n \n \n
\n\n\n\n \n\n
\n

Propertieslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
PropertyDescription
\n \n @Input()
ngPlural: number
\n
Write-Only\n \n \n \n
\n
\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n

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

\n

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

\n
    \n
  • if [ngPluralCase] is set to a value starting with =, it will only display if the value\nmatches the switch expression exactly,
  • \n
  • otherwise, the view will be treated as a \"category match\", and will only display if exact\nvalue matches aren't found and the value maps to its category for the defined locale.
  • \n
\n

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

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

Methodslink

\n \n \n\n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n addCase()\n \n link

\n \n
\n
\n
\n \n\n addCase(value: string, switchView: SwitchView): void\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n value\n string\n \n \n
\n \n switchView\n SwitchView\n \n \n
\n\n \n
Returns
\n

void

\n\n \n\n\n \n\n \n
\n
\n\n \n
\n\n \n \n \n\n
\n
\n\n\n" }