I have two directives on one page, but on another element. Something like that:
<div directive-one>
<div directive-two></div>
</div>
In directiveOne, I create some variable (say, $scope.pageConfig.variable). I want DirectiveTwo to use this variable.
Problem - directiveOne does not always load before the directive.
The question is, is there a way to make sure directiveOne is loaded before the Two directive so that the variable is accessible to the Two directive?
Thank:)
UPDATE: I found that the answer should be to use the controller in directiveOne as follows:
return {
controller: function($scope){ $scope.variable = variable; },
link : ...
}
The problem is that I get the error [$ injector: unpr] when using it this way. Should this solve my problem? Any idea why this is creating a mistake for me?