title: Angularjs: Directives load order
body: <p>I have two directives on the same page, but on a different element.
  Something like that:</p>
  
  <pre><code>&lt;div directive-one&gt;
      &lt;div directive-two&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In directiveOne, I create some variable (let's say, <code>$scope.pageConfig.variable</code>).
  I want directiveTwo to use this variable.</p>
  
  <p>The problem - directiveOne not always loads before directiveTwo.</p>
  
  <p>The question is - is there a way to make sure directiveOne loads before directiveTwo, so that the variable would be available for directiveTwo?</p>
  
  <p>Thanks :)</p>
  
  <p>UPDATE:
  I've found the answer is supposed to be to use a controller in directiveOne like this:</p>
  
  <pre><code>return {
  controller: function($scope){ $scope.variable = variable; },
  link : ...
  }
  </code></pre>
  
  <p>The problem is that I get an error [$injector: unpr] when using it this way. Should this solve my issue? Any idea why this creates an error for me?</p>