title: AngularJS - controllers communication
body: <p>On my site I have the following structure</p>
  
  <p><strong>Header_controller</strong>:</p>
  
  <pre><code>myApp.controller('Header_controller',function($scope,$rootScope,$location,Genral_model){
  
      $scope.logout = function(){
          var data = {};
          $rootScope.$emit('logout_clicked', data);  // NOT WORKING
          $rootScope.$broadcast('logout_clicked', data); // NOT WORKING
      }
  
  });
  </code></pre>
  
  <p>Users_controller:</p>
  
  <pre><code>myApp.controller('Users_controller', function ($scope,$rootScope,Users_model,$location,$state) {
  
      $rootScope.$on('logout_clicked', function(event, resp) {
          Users_model.unRegisterCookies();
      });
  })
  </code></pre>
  
  <p>Users_model:</p>
  
  <pre><code>myApp.factory('Users_model', function($rootScope,$http,$cookies) {
    var factory={};
  
    factory.unRegisterCookies = function(){
        alert('log out');
    }
  
  
    return factory;
  });
  </code></pre>
  
  <p>I'm trying to invoke <code>unRegisterCookies</code> function by sending broadcast from <code>Header_controller</code> to <code>Users_controller</code>, but it's doesn't work with emit and not with broadcast.</p>
  
  <p><strong>How to make it work?</strong></p>