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:
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
Post a Comment