I am currently experiencing an issue with an AngularJS directive. I am trying to send an outlet object from directive1 to directive2, both of which share the same controller scope. I have attempted to emit an event from directive1 to the controller, broadcast that event from the controller to directive2, and listen for the event on directive2, but it has not been successful.
Directive1:
angular.module('moduleName')
.directive('directive1', function() {
return {
restrict: 'E',
templateUrl: 'directive1.html',
scope: false,
link: function(scope) {
scope.selectOutlet = function(outlet) {
scope.order.entityId = outlet.id;
scope.navigation.currentTab = 'right';
};
}
};
In directive1, the function scope.selectOutlet() sets the outletId to scope.order.entityId. I would like to move or set that line of code to the save function in directive2.
Directive2:
angular.module('moduleName')
.directive('directive2', function(config, $rootScope, $state) {
return {
restrict: 'E',
templateUrl: 'directive2.html',
scope: false,
link: function(scope) {
scope.save = function() {
// Save functionality
// scope.order.entityId = outlet.id; This is what I would like to do
};
}
};
});
Any assistance would be greatly appreciated.