Total Pageviews

2014/06/06

[AngularJS] How to set focus on an input element as loading form

Requirement
As we entering this page, user hopes to set focus on the first input element instead of clicking the first input element by mouse.

Solution
Just set autofocus attribute in the input element
1:  <label for="year" class="control-label">年月起迄 :</label>   
2:  <input type="text" class="form-control" style="width: 45%;"   
3:        data-ng-model="model.start" id="start" name="start"   
4:         autofocus required data-c-date-picker="{format : 'yyy/MM'}" >  


Reference
[1] https://groups.google.com/forum/#!topic/angular/UcArQh7dQfQ

No comments: