Skip to content

Commit

Permalink
feat(focus): add a directive for setting focus on default fields in f…
Browse files Browse the repository at this point in the history
…orms
  • Loading branch information
beregovoy68 committed Oct 26, 2016
1 parent 97ca4b3 commit 709a6fb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/js/shared/focus.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function () {
'use strict';

angular
.module('app.shared')
.directive('focusMe', ['$timeout', function WavesFocusDirective($timeout) {
return {
restrict: 'A',
link: function (scope, element, attributes) {
scope.$watch(attributes.focusMe, function (newValue) {
$timeout(function () {
newValue && element[0].focus();
})
}, true);
}
};
}]);
})();

0 comments on commit 709a6fb

Please sign in to comment.