javascript - Angular Routes / input autofocus -


i'm using angular route. each page(route) has input field. have used attribute autofocus on first page. when navigate other pages, input not autofocus. returning first page not autofocus input again. understand why doesn't work know if there way accomplish this.

i'm new angular , i'm not sure understand read ngfocus:

https://docs.angularjs.org/api/ng/directive/ngfocus

ngfocus not you're looking for. directive more of event trigger. execute code whenever user gives focus textbox.

what want custom directive:

angular     .module('myapp')     .directive('autofocus', function($timeout) {         return {             link: function(scope, element, attrs) {                 $timeout(function() {                     element.focus();                 });             }         }     }); 

inspired http://ericclemmons.com/angular/angular-autofocus-directive/


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -