javascript - Using ngPluralize within select -


is possible use ngpluralize inside of select tag configured ngooptions pluralize options of dropdown list?

i have following controller

function ctrl ($scope) {   $scope.ranges = [1, 2, 3, 4, 5];   $scope.range = $scope.ranges[4];    $scope.$watch('range', function(val) {     console.log('change' + val);   }); }; 

and following markup

<div ng-controller="liveviewerctrl">   <select ng-model="range"            ng-options="range range in ranges"            ng-pluralize            count="range"            when="{'1': '1 minute', 'other': '{} minutes'}">   </select> </div>   

i tried create options myself using ng-repeat , worked fine. unfortunatly dropdown list had empty default value , not preselected although specified default value in controller. if use ngoptions approach preselection works, values not pluralized.

as dmitry explained, ngpluralize cannot used ngoptions, nothing stops using ngrepeat:

html:

<body ng-controller="appcontroller">    <select ng-model="selectedrange">     <option value="">select number ...</option>     <option        ng-repeat="range in ranges"       ng-pluralize       count="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];       }     ]   ); 

plunker

by way, "pre-select" troubles, aware javascript arrays zero-indexed.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -