I have a situation where I need access to several controller methods.
I can access the method from the parent directive using this:
require:"^parentDirective"
but I also need to access the method in a separate directive (not the parent), the documentation says to use an array of strings :
require:["^parentDirective","directiveTwo"]
but errors occur, although both directives were compiled into the DOM.
Did I miss something?
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; } }; });
javascript angularjs require angularjs-directive
user1005240
source share