Advertisement
Guest User

autofocus

a guest
Sep 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. angular.module('popupApp').directive('autoFocus', function($timeout, $parse) {
  2. return {
  3. restrict: 'AC',
  4. scope: { trigger: '=autoFocus' },
  5. link: function(scope, element, attrs) {
  6. scope.$watch('trigger', function(value) {
  7. if(value === true) {
  8. $timeout(function() { element[0].focus(); }, 500);
  9. scope.trigger = false;
  10. }
  11. });
  12. }
  13. };
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement