More angular way? Just use the directives . Basically, you can get the controller * of the parent directive inside the child directive. Treat the parent controller as an API for its children / children.
.directive('parent', function() { return { controller: function() { this.catchChild = function(child) {
I updated your plnkr for you: http://plnkr.co/edit/qRURHRMWt9K5acLWmCHv?p=preview
(*) You can pass multiple directives as an array
angular.module('app', []) .directive('parent1', function() { return { controller: function() { this.fn1 = function(child) { // code... }; } }; }) .directive('parent2', function() { return { controller: function() { this.fn2 = function(child) { // code... }; } }; }) .directive('child', function() { return { require: ['^parent1', '^parent2'], link: function($scope, $element, $attrs, controllers) { var parent1Controller = controllers[0]; var parent2Controller = controllers[1]; parent1Controller.fn1(); parent2Controller.fn2(); } }; })
hinok source share