Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-options add suffix to each option

Suppose i have the following array with strings:

$scope.open_slots = ["00","10","50"], and i would like to have the following results:

enter image description here

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

how can i just add suffix to each item in the select option list?

this is my code:

 <select data-ng-model="minutes_per_slot" data-ng-options="item for item in open_slots"></select>
like image 785
Liad Livnat Avatar asked Dec 04 '25 19:12

Liad Livnat


2 Answers

You can do it using the as part of the ngOptions:

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

See, also, this short demo.

like image 117
gkalpak Avatar answered Dec 07 '25 08:12

gkalpak


Try:

<select data-ng-model="minutes_per_slot" 
        data-ng-options="item as item + ' minutes' for item in open_slots">
like image 31
pixelbits Avatar answered Dec 07 '25 09:12

pixelbits



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!