I am implementing an angular chosen function on my select
tag.
Below is the code for 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 select
tag above is populated from this 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'};
This object contains pairs of values and options for the select
tag where the key
represents the option's value and the value
represents the option's text.
I want to set the default value of the select
tag to 'CustomReport' as the option value and 'Custom Report Name' as the option text using ng-init
, but it seems to not work.
Is there a way to correctly set the default value based on the object's key-value pair?