I have a select
tag to which I am applying angular chosen.
This is my select
tag
<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>
The above select
tag is getting populated from below object
$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'};
The object is a pair of values and options for select
tag where the key
is options tags value
and the value
is the option tag text
Now I want to set the default value of the select
tag to 'CustomReport'
as its option value
and 'Custom Report Name'
as its option text
from the above object, using ng-init
.
I tried doing ng-init="rname='CustomReport'"
, but it doesn't work
How to set its value from object's key value pair?