ng-options为每个选项添加后缀 [英] ng-options add suffix to each option
本文介绍了ng-options为每个选项添加后缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有以下带字符串的数组:
Suppose i have the following array with strings:
$ scope.open_slots = [00,10,50 ]
,我希望得到以下结果:
$scope.open_slots = ["00","10","50"]
, and i would like to have the following results:
不执行此操作: $ scope.open_slots = [00 minutes, 10分钟,50分钟]
如何为选项选项列表中的每个项目添加后缀?
how can i just add suffix to each item in the select option list?
这是我的代码:
<select data-ng-model="minutes_per_slot" data-ng-options="item for item in open_slots"></select>
推荐答案
你可以使用 as
部分 ngOptions
:
ng-options="slot as slot+' minutes' for slot in open_slots">
另请参阅此 简短演示 。
See, also, this short demo.
这篇关于ng-options为每个选项添加后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文