Ng-Pluralize-3

 

In this example we have a dropdown with the values from 0 to 3. If user select 0 then ng-pluralize directive will show No room available for count 1 it will show One room available and so on.

 
 
 
<!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" ng-init="rooms=[0,1,2,3]"> <div class="col-md-3"> <select class="form-control" ng-model="room" ng-options="room as room for room in rooms"></select> <ng-pluralize count="room" when="{'0':'No rooms available', '1':'{{room}} rooms available', '2':'{{room}} rooms available', '3':'{{room}} rooms available', }"> </ng-pluralize> </div> </div> </div> <script> var app = angular.module("pluralizeExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.room = 0; }]); </script> </body> </html>
Output