I have two directives, lets say:
angular.module('app').directive('directiveA', directiveA);
function directiveA(){
return {
restrict: 'E',
transclude: true,
scope: {},
templateUrl: 'directiveA.html',
controller: function($scope){
$scope.test="test data";
}
};
}
And second one:
angular.module('app').directive('directiveB', directiveB);
function directiveB(){
return {
restrict: 'E',
require: '^directiveA',
transclude: true,
scope: {},
templateUrl: 'directiveB.html',
link: function(scope, elem, attrs, directiveAController) {
console.log("directiveB linked");
}
};
}
HTML for directiveA:
<div>
<!-- something here -->
<div ng-transclude></div>
</div>
HTML for directiveB:
<div>{{test}}</div>
And I wanna use them like this:
<directive-a>
<directive-b></directive-b>
</directive-a>
How can I make them communicate with each other using require and ng-transclude and have both templates rendered ? For example I would like to print test variable from directiveA in directiveB template. I am new to directives and transclusion.