Ng-Pluralize-4

 

In this example we have textarea to enter the names of the persons. Write comma seprated names in the textarea and the ng-pluralize directive will show about the entered names that these persons are viewing.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="pluralizeExample"> <div ng-controller="ExampleController"> <div class="container"> <div class="col-md-3"> <p>Type in a list of comma ( , ) separated names.</p> <textarea class="form-control" ng-model="people" ng-list=","></textarea> <pre>{{people|json}}</pre> <ng-pluralize count="people.length" offset="2" when="{ '0': 'Nobody is viewing.', '1': '{{people[0]}} is viewing.', '2': '{{people[0]}} and {{people[1]}} are viewing.', 'one': '{{people[0]}}, {{people[1]}} and one other person is viewing.', 'other': '{{people[0]}}, {{people[1]}} and {} other people are viewing.'}"> </ng-pluralize> </div> </div> </div> <script> var app = angular.module("pluralizeExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.people = []; }]); </script> </body> </html>
Output