For the Html5,input element has the autofocus this attribute, the user can interact with the user when the first time enters the interface, for the browser, may
Positioning the keyboard focus on an element, but for non-input elements, we can use directives to achieve focus positioning.
1:html file:
2:autofocus.js Directive File
3:directctrl.js Controller Files
(function() { ' use strict '; var mymodule = angular.module (' Mydirectapp ', []); Mymodule.controller (' Directcontroller ', [' $scope ',function($scope) { = ' No click! '; function () { = ' When you click Confirm! '; }; function () { = ' click Reset! ' ; }; }]);}) ();
Note: In the main Page load JS file, to load the Autofocus.js file first, and then load the Directctrl.js file, otherwise it will be an error.
angular-1.3.8.js:11594 Error: [ng:areq] Argument ' Directcontroller ' is not a function, got undefined
This controller is not recognized.
Modifying the DOM with instructions