Default value in select box
If you want to make an option default in select column you
can add selected in html. If you want to do this in angular.js there are
solutions. Given below is the code for select tag.
<select ng-init="somethingHere = options[0]" ng-model="somethingHere" ng-options="option.name for option in options"></select>
The values a supplied using below code.
options = [{name: 'Something Cool-1',
value: 'something-cool-1-value'
}, {
name: ' Something Cool-2',
value: ' something-cool-2-value'
}];
This gives the output:
<select ng-init="somethingHere = options[0]" ng-model="somethingHere" ng-options="option.name for option in options"><option value="0" selected="selected"> Something Cool </option>
<option value="1"> Something Cool-1 </option>
<option value="2"> Something Cool-2 </option>
</select>
Comments
0 comments
Please Sign in or Create an account to Post Comments