javascript - AngularJS Select element set the selected index -
so i'm using angular , select html:
<select id="date" ng-model="selectedday" ng-change="setdate()" > <option>another option</option> <option>an option</option> </select>
this in controller:
$scope.selectedday; document.getelementbyid("date").selectedindex = "0";
the result: 3 options: 1 blank (which default selected) , 2 options made in html
what hell? why isn't default when open view "another option"
firstly, check official documentation. angularjs documented.
secondly, not utilize document.getelementbyid ("date") selectedindex = "0"
- that's javascript. avoid using pure javascript when angular function available.
documentation:
https://docs.angularjs.org/api/ng/directive/select
https://docs.angularjs.org/api/ng/directive/ngselected
javascript html angularjs default selectedindex
No comments:
Post a Comment