Using Ngpluralize Within Select
Is it possible to use ngPluralize inside of a select tag configured with ngOoptions to pluralize the options of the dropdown list? I currently have the following controller functio
Solution 1:
As Dmitry explained, ngPluralize
cannot be used with ngOptions
, but nothing stops you from using it with ngRepeat
:
HTML:
<bodyng-controller="AppController"><selectng-model="selectedRange"><optionvalue="">Select number ...</option><optionng-repeat="range in ranges"ng-pluralizecount="range"when="{1: '{{range}} minute', other: '{{range}} minutes'}"
>{{range}}</option></select></body>
JS:
app.controller('AppController',
[
'$scope',
function($scope) {
$scope.ranges = [1, 2, 3, 4, 5];
$scope.selectedRange = $scope.ranges[4];
}
]
);
By the way, about your "pre-select" troubles, be aware that JavaScript arrays are zero-indexed.
Post a Comment for "Using Ngpluralize Within Select"