Best practice for these kind of things is the require
property in directives, you should be able to require the controller of directive-1
and through that access its scope.
But now you also have a shareable API between directives.
app.directive('directive1', function () {
return {
require: '^directive1',
controller: ['$scope', function ($scope) {
this.$scope = $scope;
this.sharedFn = function () {
};
return this;
}]
};
});
app.directive('directive2', function () {
return {
require: '^directive1',
link: function (scope, element, attrs, directive1Ctrl) {
console.log(directive1Ctrl);
}
};
});
app.directive('directive3', function () {
return {
require: '^directive1',
link: function (scope, element, attrs, directive1Ctrl) {
console.log(directive1Ctrl);
}
};
});
Hope this helps