From beee5a3003314372604b36a26cd0b1e101ca5699 Mon Sep 17 00:00:00 2001 From: Andrew Hart Date: Tue, 21 Oct 2014 16:42:40 -0700 Subject: [PATCH] Add focus directive to be used to give input elements focus --- public/src/js/directives.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/src/js/directives.js b/public/src/js/directives.js index 2d2e7f6..4426c42 100644 --- a/public/src/js/directives.js +++ b/public/src/js/directives.js @@ -72,4 +72,20 @@ angular.module('insight') }); } }; + }) + .directive('focus', function ($timeout) { + return { + scope: { + trigger: '@focus' + }, + link: function (scope, element) { + scope.$watch('trigger', function (value) { + if (value === "true") { + $timeout(function () { + element[0].focus(); + }); + } + }); + } + }; });