I'm facing a challenge trying to set the default value for a select box. Despite my efforts, I can't seem to figure out what's going wrong. Here is the code snippet:
<select class="form-control" ng-init="newQuestion.positionOnSurvey=vm.questionsPositions[0]" ng-model="newQuestion.positionOnSurvey">
<option ng-repeat="position in vm.questionsPositions track by $index" value="{{position}}">{{position}}</option>
</select>
The value of vm.questionsPositions[0] is 5, so that shouldn't be the issue. Although I am not initializing newQuestion in my controller, it should work with ng-init, right?
UPDATE:
I have updated my approach to initializing the field like this, but unfortunately, it is still not functioning as expected.
vm.newQuestion = {};
vm.newQuestion.positionOnSurvey = vm.questionsPositions[0];
<select class="form-control" ng-model="vm.newQuestion.positionOnSurvey">
<option ng-repeat="position in vm.questionsPositions track by $index" value="{{position}}">{{position}}</option>
</select>