0
<DirectiveName value1="someValue"  functionRef="someFunction()"></DirectiveName>
angular.module('Name', ['Dependencies']).
        directive('DirectiveName',
                function($timeout) {
                    return {
                        restrict: 'AE',
                        replace: 'true',
                        template : 'HTML Template',
                        scope: {
                            variable1: '=value1',
                            Variable2: '&functionRef',
                        },
                        link: function(scope, watch){
                            
                        }
                    };
                });
  1. I am using this angular JS custom directive, where we are passing reference of method from HTML to get called.
  2. Now we want to execute another function as well after execution of referenced function i.e. Variable2

We can not call common function from HTML or parent controller hence we need to call common function from angular directive it self after the execution of referenced function i.e. Variable2

2 Answers2

0
I think you are still using angular 1. If that is true then check below link. Hope it will help you. If not then 'output' (eventEmitter) present in angular version > 2 

1.http://www.binaryintellect.net/articles/5d8be0b6-e294-457e-82b0-ba7cc10cae0e.aspx
2.https://stackoverflow.com/questions/47639275/using-emit-to-pass-a-function-from-child-to-parent-in-angularjs
TValidator
  • 39
  • 1
0
angular.module('Name', ['Dependencies']).
        directive('DirectiveName',
                function($timeout) {
                    return {
                        restrict: 'AE',
                        replace: 'true',
                        template : 'HTML Template',
                        scope: {
                            variable1: '=value1',
                            Variable2: '&functionRef',
                        },
                        link: function(scope, element, attr){
                            scope.Variable2 = function(){
                                
                                scope.$parent.$eval(attr.functionRef);
                                
                                /* other statement goes here */ 
                            }
                        }
                    };
                });

Overriding function works, call referenced function from inside overridden function using $eval()