diff --git a/lib/index.js b/lib/index.js index de59aff..032a993 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,11 +5,13 @@ app = angular.module('focusOn', []); app.directive('focusOn', function() { return function(scope, elem, attr) { - return scope.$on('focusOn', function(e, name) { - if (name === attr.focusOn) { - return elem[0].focus(); - } - }); + if(attr.focusOn){ + return scope.$on('focusOn', function(e, name) { + if (name === attr.focusOn) { + return elem[0].focus(); + } + }); + } }; });