1

I have an Angular 1.5 system comprising of several nested Components. I now need to use a Directive (this needs to be an attribute) which will be embedded within a Component.

How can I call a function in the parent Component from the child Directive? What is the correct syntax for somehow exposing a method in the parent Component so that an event in the child Directive can call it?

Journeyman
  • 10,011
  • 16
  • 81
  • 129
  • Via `require`. [RTM](https://docs.angularjs.org/guide/component#intercomponent-communication). See also https://stackoverflow.com/questions/35293680/using-require-in-angular-component . – Estus Flask Feb 22 '17 at 15:37
  • Possible duplicate of [AngularJS access parent scope from child controller](http://stackoverflow.com/questions/21453697/angularjs-access-parent-scope-from-child-controller) – Amir Suhail Feb 28 '17 at 07:27

1 Answers1

0

You can use in child element $scope.$emit('EventName', attrObject); or $rootScope.$broadcast('EventName', attrObject);

And in parent controller

 $scope.$on('EventName', function(event, attrObject){ 
//your code calling function you want to use
}