title: angularjs controller access directive scope value
body: <p>I have this controller with directive inside my html code. The directive have scope value I would like access from the parent controller and show in the html. Hope my example code give you a simple overview of what I'm trying to achieve. </p>
  
  <p>I know this work using $rootScope.showvalue = 'pass text'; in the directive works but don't know if this is the best solution. </p>
  
  <pre><code>app.directive('customdir', [function() {
    return {
      restrict:   "E",
      scope:      {    
        showvalue: "="
      },
      link: function(scope, el, attrs) {
        scope.showvalue = 'pass text';
  
      }
    };  
  }]);
  
  app.controller('mycontroller', function($scope) {
    alert($scope.showvalue); 
  });
  
  
  
  &lt;html&gt;
       &lt;div ng-controller="mycontroller"&gt;
          &lt;custom-dir&gt;&lt;/custom-dir&gt;
  
             /* Show scope value from custom dir */
  
            {{showvalue}}
       &lt;/div&gt;
    &lt;/html&gt;
  </code></pre>