title: Call a method from one controller defined inside directive in another controller : AngularJS
body: <p>I have a directive in which controller exists, where i have a function. I need to call that function from another controller.</p>
  
  <p>Directive :</p>
  
  <pre><code>    angular.module('test.directives').directive("manageAccess", function() {
          return {
              restrict: "E",
              replace: true,
              templateUrl: "template/test.html",
              controller: function($scope, $element, $http) {
                  $scope.getRoles = function() {
                      console.log('hi');
                  };
              }
          };
      });
  </code></pre>
  
  <p>$scope.getRoles method is the method i need to call from different controller.</p>
  
  <p>Controller:</p>
  
  <pre><code>    angular.module("test.controllers").controller("testController", function($scope, $http) {
          $scope.getUsers = function() {
              // i need to call getRoles method here
          }
      });
  </code></pre>
  
  <p>How can i do that?</p>
  
  <p>Please help,
  Thanks.</p>