码迷,mamicode.com
首页 > Web开发 > 详细

[AngularJS] ngPluralize

时间:2015-12-21 07:02:21      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

 

ngPluralize is a directive that displays messages according to en-US localization rules. 

 

<script>
  angular.module(‘pluralizeExample‘, [])
    .controller(‘ExampleController‘, [‘$scope‘, function($scope) {
      $scope.person1 = ‘Igor‘;
      $scope.person2 = ‘Misko‘;
      $scope.personCount = 1;
    }]);
</script>
<div ng-controller="ExampleController">
  <label>Person 1:<input type="text" ng-model="person1" value="Igor" /></label><br/>
  <label>Person 2:<input type="text" ng-model="person2" value="Misko" /></label><br/>
  <label>Number of People:<input type="text" ng-model="personCount" value="1" /></label><br/>

  <!--- Example with simple pluralization rules for en locale --->
  Without Offset:
  <ng-pluralize count="personCount"
                when="{‘0‘: ‘Nobody is viewing.‘,
                       ‘one‘: ‘1 person is viewing.‘,
                       ‘other‘: ‘{} people are viewing.‘}">
  </ng-pluralize><br>

  <!--- Example with offset --->
  With Offset(2):
  <ng-pluralize count="personCount" offset=2
                when="{‘0‘: ‘Nobody is viewing.‘,
                       ‘1‘: ‘{{person1}} is viewing.‘,
                       ‘2‘: ‘{{person1}} and {{person2}} are viewing.‘,
                       ‘one‘: ‘{{person1}}, {{person2}} and one other person are viewing.‘,
                       ‘other‘: ‘{{person1}}, {{person2}} and {} other people are viewing.‘}">
  </ng-pluralize>
</div>

 

[AngularJS] ngPluralize

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5062361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!