// http://stackoverflow.com/questions/17556703/angularjs-directive-call-function-specified-in-attribute-and-pass-an-argument-to MetronicApp.directive('onAfterRender', function ($timeout, $parse) { return { restrict: 'A', link: function (scope, element, attr) { if (scope.$last === true) { $timeout(function () { var expressionHandler = $parse(attr.onAfterRender); expressionHandler(scope, {}); }); } } } });