Reputation: 2377
I am using ng-options to create select options. CA.JSON file has all the controls values/options.
Here in for VehicleYear option I want to add default please select option.
<select>
<option value="">Please select</option>
<option value="2017">2017<option>
...
<select>
I tryed as below but its not working
<select ng-change="updateMakeList" custom-required="true" ng-options="ans._value as ans._promptText for ans in questions[$state.current.name].VehicleYear.QuestionData._answerOptions" ng-model="answers.VehicleYear" ng-required="queObj._required" class="form-control {{queObj._pageAttributes.cssclass}}" name="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" id="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" data-que-obj="questions[$state.current.name].VehicleYear.QuestionData" select-control-dir setMake custom-required>
<option value="">Please select</option>
</select>
https://plnkr.co/edit/aV65Nab9U9I6YlK2g4sY?p=preview
Upvotes: 0
Views: 347
Reputation: 3507
try to use below code for select
<select ng-init="selectModal= Please Select"
ng-model="selectModal"
ng-options="option.name for option in options">
</select>
// where options is your options array in your case i think its questions[$state.current.name].VehicleYear.QuestionData._answerOptions
you can also try by adding option as below
<option style="display:none" value="">Please select</option>
When you try to assign value to option which is not in options array or set this problem occurs
Upvotes: 0