(function () { 'use strict'; var app = angular.module('sysMgrApp'); app.directive('smFocus', [ '$timeout', function ($timeout, $parse) { return { restrict: 'A', link: function (scope, element, attribute) { var attribValue = attribute.smFocus; if (attribValue == '') attribValue = true; else attribValue = scope.$eval(attribValue); console.log('Element Id= ' + element[0].attributes["id"].value + ' attribValue=' + attribValue); if (attribValue== true) { scope.$on('sm:focus', function () { $timeout(function () { element[0].focus(); }, 10); }); } } }; }]); })();It is probably bad code, but seems to be working. If I have sm-focus it works and if I have it with the value of the variable, it seems to work as well (although I had to change the controller to define that variable earlier).