I have the situation where i need access to multiple directive controller methods.
I can access a method from a parent directive using the require like so:
require:"^parentDirective"
but I also need to access a method within a seperate directive (not a parent), the documentation says to use an array of strings like so:
require:["^parentDirective","directiveTwo"]
but doing this causes errors although the both directives have been compiled to the DOM.
Am I missing something here?
here is my directive:
angular.module('testModule', ['parentModule'], function () {
}).directive('testDirective', function() {
return {
restrict: 'AE',
templateUrl: 'testTemplate.tpl.html',
scope: {
value1: "=",
value2: "="
},
require:['^parentDirective','otherDirective'],
controller: function($scope,$modal,socketConnection) {
if(case_x == true){
$scope.requiredController_1.ctrl1Func();
}
else if(case_x == false){
$scope.requiredController_2.ctrl2Func();
}
},
link: function(scope,element,attrs,requiredController_1,requiredController_2){
scope.requiredController_1 = requiredController_1;
scope.requiredController_2 = requiredController_2;
}
};
});