title: AngularJS: Scope variable undefined within controller
body: <p>I create a new Scope within a directive like this</p>
  
  <pre><code>controllersModule.directive('uploadBox', function() {
  return {
      restrict: 'E',
      scope: {
          topic: '=topic',
          label: '=label'
      },
      templateUrl: '/assets/directives/uploadBox.html'
  };});
  </code></pre>
  
  <p>And use this directive like this (both values -label and topic- are values, which are stored in JSON files, within two different controllers)</p>
  
  <pre><code>&lt;upload-box label="lc.getTerm('system_upload')" topic="tc.currentTopic.uID"&gt;&lt;/upload-box&gt; 
  </code></pre>
  
  <p>So the attribute label and topic are both passed to the new (created) Scope. Now, the funny thing is, while I'm able to access both values within the template HTML file (uploadBox.html)</p>
  
  <pre><code>&lt;div ng-controller="DropUploadCtrl"&gt;
      &lt;button class="btn btn-success" dropzone="dropzoneConfig"&gt;
          &lt;!-- label is correctly shown --&gt;
          {{ label }}
      &lt;/button&gt;
  
      &lt;!-- this link works fine: Evaluates to something like aaa/54dg54...SHA128-Hash...G4FX--&gt;
      &lt;a ng-href="aaa/{{ topic }}"&gt;BB&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Only the label value is accessible from within the DropUploadController.</p>
  
  <pre><code>controllersModule.controller('DropUploadCtrl', ['$scope',function($scope) {
  var that = this;
  
  console.log($scope.label); // this is working fine
  console.log($scope.topic); // this is undefined
  
  // some more stuff here
  
  }]);
  </code></pre>
  
  <p>I know that scopes are created for specific controllers and you cannot share scope variables directly between two controllers. However, I don't think that this is a problem here because I can use the label value. But, where am I wrong respectively what is wrong in my code?</p>
  
  <p>Thank you very much</p>
  
  <p>EDIT:</p>
  
  <p>The output for the rootScope within the controller </p>
  
  <pre><code>console.log("$scope::&gt;"); 
  console.log($scope.label); 
  console.log($scope.topic); 
  console.log("$rootScope::&gt;") 
  console.log($rootScope.label); 
  console.log($rootScope.topic); 
  </code></pre>
  
  <p>looks like this:</p>
  
  <pre><code>"$scope::&gt;" 
  "I'm a label" 
  undefined 
  "$rootScope::&gt;" 
  undefined 
  undefined 
  </code></pre>
  
  <p>Furthermore, the value is undefined in the link function of the directive</p>
  
  <p>Edit2: The solution has been found!
  The value in tc.currentTopic.uID was not filled at the moment the other controller was initializing. That's why the expression {{topic}} was working fine because it has been evaluated again, when the value has changed, a couple of ms later. I fetch the data now directly via $routeParams.</p>