<CustomDirective customValue="someValue" anotherFunctionRef="anotherFunction()"></CustomDirective>
angular.module('AppName', ['OtherDependencies']).
directive('CustomDirective',
function($timeout) {
return {
restrict: 'AE',
replace: 'true',
template : 'Some HTML Content',
scope: {
value1: '=customValue',
value2: '&anotherFunctionRef',
},
link: function(scope, watch){
}
};
});
- This is an angular JS custom directive that passes a reference of a method from the HTML to be called.
- Our goal is to also execute another function after the referenced function (value2) has finished running.
Since we cannot call a common function directly from the HTML or parent controller, we need to call it from within the angular directive itself after the execution of the referenced function (value2).