Ng-options add a suffix to each option

Suppose I have the following array with strings:

$scope.open_slots = ["00","10","50"]

and I would like to get the following results:

enter image description here

without doing this: $scope.open_slots = ["00 minutes","10 minutes","50 minutes"]

how can I just add a suffix to each item in the list of select options?

this is my code:

 <select data-ng-model="minutes_per_slot" data-ng-options="item for item in open_slots"></select>

      

+3


source to share


2 answers


You can do it using the as

part ngOptions

:

ng-options="slot as slot+' minutes' for slot in open_slots">

      




See also this short demo .

+11


source


Try:



<select data-ng-model="minutes_per_slot" 
        data-ng-options="item as item + ' minutes' for item in open_slots">

      

+2


source







All Articles