最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ng-options add suffix to each option - Stack Overflow

programmeradmin0浏览0评论

Suppose i have the following array with strings:

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

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>

Suppose i have the following array with strings:

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

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>
Share Improve this question asked Aug 7, 2014 at 8:24 Liad LivnatLiad Livnat 7,47517 gold badges61 silver badges98 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

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.

Try:

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

评论列表(0)

  1. 暂无评论