我有一个select
标签,我正在应用角度选择。
这是我的select
标签
<select name="rname" id="rname" ng-model="rname" ng-init="rname='CustomReport'"
ng-options="key as value for (key , value) in reportsValuesOptions track by key" chosen>
<option value="">---Select---</option>
</select>
上面的select
标签是从下面的对象中填充的
$scope.reportsValuesOptions = {'Cash Position Report':'Cash Position Report','Detail Report':'Detail Report','Reconciliation Report':'Reconciliation Report','Summary Report':'Summary Report','Sweep Report':'Sweep Report','FCCS/FBPS Detail Report':'FCCS/FBPS Detail Report','CustomReport':'Custom Report Name'};
select
该对象是标签的一对值和选项,其中is和the is thekey
options tags value
value
option tag text
现在我想将select
标签的默认值设置为'CustomReport'
as itsoption value
和'Custom Report Name'
as its option text
from the above object,使用ng-init
.
我试过做ng-init="rname='CustomReport'"
,但它不起作用
如何从对象的键值对中设置其值?