title: AngularJS: Access directive's isolated scope from parent controller
body: <p>I want to write a directive with isolated scope but also want to make that scope available for the parent scope's controller. I found this solution:</p>
  
  <pre><code>&lt;div ng-controller="Main"&gt;
    &lt;popupbutton directive-scope="popup"&gt;&lt;/popupbutton&gt;
  &lt;/div&gt;
  
  app.directive('popupbutton', [function() {
    return {
      restrict:   "E",
      scope:      {    
        directiveScope: "="
      },
      link:       function(sc, el, attrs) {
        sc.directiveScope = sc;
        sc.testvalue = 'foo';
      }
    };  
  }]);
  
  app.controller('Main', function($scope) {
    alert($scope.popup.testvalue);  // Where did the property 'popup' come from?!?
  });
  </code></pre>
  
  <p>See <a href="http://plnkr.co/edit/M9EWGGGqSPvEUGn1EMcB?p=preview" rel="noreferrer">Plunker</a>.</p>
  
  <p>I find this a bit ugly because it involves writing an attribute in HTML and in controller's code you can't tell where a scope property came from. Is there a better way to do this?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Besides, it seems that $scope.popup isn't even available when controller 'Main' is run. The directive's linking function isn't executed yet?</p>