[英]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: $scope.open_slots = ["00","10","50"]
,我希望得到以下结果:
without doing this : $scope.open_slots = ["00 minutes","10 minutes","50 minutes"]
不这样做:
$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>
You can do it using the as
part of the ngOptions
: 您可以使用做到这一点
as
的一部分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">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.