I have this directive (which I will cut down for brevity):
.directive('simpleConfigurator', function () {
return {
restrict: 'A',
scope: {
garment: '=simpleConfigurator',
colours: '=',
onComplete: '&'
},
require: ['designs', 'colours'],
transclude: true,
templateUrl: '/assets/tpl/directives/kit.html',
link: function (scope, element, attrs, controllers) {
scope.svgPath = 'assets/garments/' + scope.garment.slug + '.svg';
// Executes after the svg has loaded
scope.loaded = function () {
scope.$broadcast('loaded', { loaded: true });
};
}
};
})
The HTML for this looks like this:
<div ng-transclude></div>
<div id="{{ garment.slug }}" ng-include="svgPath" onload="loaded()"></div>
I am trying to get it to communicate with other directives. So in my designs directive, I have this:
.directive('designs', function () {
return {
restrict: 'A',
controller: 'ConfiguratorDesignsDirectiveController',
link: function (scope) {
scope.$on('loaded', function () {
console.log('we have loaded');
});
}
}
})
I was hoping that I would get a console log stating we have loaded but I didn't. I assume it is because both "designs" and "colours" are considered the parents and the child is the directive that requires them.
Is there another way I can communicate with the parent directives or is there a way to get this to work?