我试过这个,但它不起作用: 现在在Angular 1.3.4中实现。
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
</head>
<body ng-app="">
<input type="number" ng-model="foo" ng-init="foo=1"><hr>
Normal binding: <ng-pluralize count="foo" when="{'0': 'zero', '1': 'one', 'other': 'many'}"></ng-pluralize><hr>
One-time binding: <ng-pluralize count="::foo" when="{'0': 'zero', '1': 'one', 'other': 'many'}"></ng-pluralize>
</body>
</html>
是否有使用ng-pluralize
的其他方法?
答案 0 :(得分:2)
Blackhole的建议有效(谢谢!)
// Blackhole's suggestion, try here: http://plnkr.co/edit/roxHzV?p=preview
<ng-pluralize count="{{ ::foo }}" when="{'0': 'zero', '1': 'one', 'other': 'many'}"></ng-pluralize>
我期待count="::foo"
能够工作,所以我打开了an issue on GitHub。来自Angular团队的Caitp表示赞同并且目前计划用于Angular 1.3.4。