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:
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 to share