title: How to require a controller in an angularjs directive
body: <p>Can anyone tell me how to include a controller from one directive in another angularJS directive.
  for example I have the following code</p>
  
  <pre class="lang-js prettyprint-override"><code>var app = angular.module('shop', []).
  config(['$routeProvider', function ($routeProvider) {
      $routeProvider.when('/', {
          templateUrl: '/js/partials/home.html'
      })
          .when('/products', {
          controller: 'ProductsController',
          templateUrl: '/js/partials/products.html'
      })
          .when('/products/:productId', {
          controller: 'ProductController',
          templateUrl: '/js/partials/product.html'
      });
  }]);
  
  app.directive('mainCtrl', function () {
      return {
          controller: function ($scope) {}
      };
  });
  
  app.directive('addProduct', function () {
      return {
          restrict: 'C',
          require: '^mainCtrl',
          link: function (scope, lElement, attrs, mainCtrl) {
              //console.log(cartController);
          }
      };
  });
  </code></pre>
  
  <p>By all account I should be able to access the controller in the addProduct directive but I am not. Is there a better way of doing this? </p>