(function () { 'use strict'; var name = 'adAutofocus'; angular.module('app.directive') .directive('adAutofocus', ['$timeout', function ($timeout) { return { scope: false, link: function (scope, element, attr) { scope.$watch(attr[name], function (val) { if (angular.isDefined(val) && val) { $timeout(function () { element[0].focus(); }); } }, true); } }; }]); })();