title: How to communicate between controllers of two different modules in AngularJs
body: <p>I want to know that can we communicate between two different controllers in AngularJS. Suppose  I have Two modules,<br>
  Plunker: <a href="http://plnkr.co/edit/if0MQwlx9WHrD8XnMi2t?p=preview" rel="nofollow">http://plnkr.co/edit/if0MQwlx9WHrD8XnMi2t?p=preview</a></p>
  
  <pre><code>    1. var app = angular.module('fistModule', []);
             app.controller('first', function ($scope) {
                  $scope.firstMethod= function () {
                   //my code}
  } )
      2. var newapp = angular.module('secondModule,[]');
             newapp.controller('second', function ($scope) {
                $scope.secondMethod= function () {
                 //my code}
  </code></pre>
  
  <p>Is there way to communicate between controllers of two different modules.</p>
  
  <p>My Code:
  JS:</p>
  
  <pre><code>angular.module('myApp', [])
    .controller('ParentCtrl', ['$scope',
      function($scope) {
  
        $scope.message = "Child updated from parent controller";
  
        $scope.clickFunction = function() {
          $scope.$broadcast('update_parent_controller', $scope.message);
        };
      }
    ]);
    angular.module('myNewApp', [])
    .controller('ChildCtrl', ['$scope',
      function($scope) {
        $scope.message = "Some text in child controller";
  
        $scope.$on("update_parent_controller", function(event, message) {
          $scope.message = message;
        });
      }
    ])
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div ng-app="myApp" ng-controller="ParentCtrl"&gt;
  
      &lt;div ng-app="myNewApp" ng-controller="ChildCtrl"&gt;
        &lt;p&gt;{{message}}&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;button ng-click="clickFunction()"&gt;Click&lt;/button&gt;
    &lt;/div&gt;
  </code></pre>