Permalink
Browse files

feat(focus): add a directive for setting focus on default fields in f…

…orms
  • Loading branch information...
1 parent 97ca4b3 commit 709a6fb1b4d5829f8a6249f273025185ec49b262 @beregovoy68 beregovoy68 committed Oct 26, 2016
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/js/shared/focus.directive.js
@@ -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.