I would like to pass the value of an ng-model that the user sets in a another form field select options to another ng-model as initial value in the same form.
In this example, I want the ng-init value of myModel.fieldB
to be the value myModel.fieldA.subfield
, this is successfully evaluating in the value of the span element, but not in the ng-model for myModel.fieldB
, meaning that nothing is happening in ng-init="myModel.fieldB = myModel.fieldA.subfield"
.
However when I pass string literal values, it works, for example ng-init="myModel.fieldB = 'some example'"
<span class="form-group" ng-model="myModel.fieldB" ng-init="myModel.fieldB = myModel.fieldA.subfield">{{myModel.fieldA.subfield}</span>