Javatpoint Logo
Javatpoint Logo

AngularJS ng-pluralize Directive

The AngularJS ng-pluralize directive is used to display message according to en-US localization rules. These rules are bundled with AngularJS but cannot be overridden. The ng-pluralize directive is configured by specifying the mapping between plural categories and the displaying strings.


It is of two types:

1.Simple pluralization:

Syntax:

Parameter explanation:

count: It is a string or expession specifying the variable to be bound to.

when: It is a string specifying the mapping between plural category to its corresponding strings.

See this example:

Test it Now

2.Configuring ng-pluralize with offset

The offset attribute facilitates you to further customization of pluralized text which provides better user experience.

For example: If there are 4 people in the hall and the message is displaying as 4 people are watching this movie. Instead of this message, you can display: Ajeet, Aryan and 2 others are watching this movie."

The offset attribute facilitates you to offset a number by any desired value.

Syntax:

Parameter explanation:

count: It is a string or expession specifying the variable to be bound to.

when: It is a string specifying the mapping between plural category to its corresponding strings.

offset: It is optional. It specifies a number, offset to deduct from the total number.

See this example:


See this example:





Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA