I have a <select>
in a form with other fields, like so-
<form class="formCSS">
<div class="inputs">
<label class="labelTag">Name *:   </label>
<select class="inputTag" ng-model="selectedName"
ng-options="n.name for n in adminNames"></select>
</div>
</form>
adminChannels
is an object array of this structure {_id:"....", name:"..."}
When I "transitionTo" this state, I pass a name (which exists in adminNames too) like so -
$state.go('schedule',{name:response.name});
I want the said name (accessed using $scope.name
) to be pre-selected when this template loads.
I tried something like this -
ng-init = "selectedName=adminNames[adminNames.indexOf(name)]"
I do get the auto-populated drop-down menu but nothing gets selected as default.
I went through all other posts about selecting default options, none of them provide info about pre-selecting using $scope variable.
Please let me know if I've to provide any more info/code. Thanks in advance!