VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-pluralize-directive/

⇱ AngularJS ng-pluralize Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-pluralize Directive

Last Updated : 16 Aug, 2022

The ng-pluralize Directive in AngularJS is used to specify the message to display according to the en-us localization rules. The en-us localization rules are bundled with AngularJS. The default plural category in AngularJS is "one" and "other". 

Syntax: The ng-pluralize Directive can be used:

As element:

<ng-pluralize count="" when="string" [offset="number"]>
 Contents...
</ng-pluralize>

As attribute:

<element ng-pluralize count="" when="string"
 [offset="number"]>
 Contents...
</element>

Parameter Values:

  • count: It refers to the value of the count attribute which is used by Angular expression.
  • when: It is used to specify the mapping between the actual string and the plural categories. The attribute value must be in JSON object style.
  • offset: It specifies the offset attribute to deduct from the total number.

Example 1: This example uses the ng-pluralize Directive to display content. 

Output:

👁 Image
 

 Example 2: This example uses the ng-pluralize Directive to display the input text content. 

Output:

👁 Image
 
Comment

Explore