title: AngularJS (1.2.25) $rootScope.$broadcast('message',data) not being received by $scope.$on('message')
body: <p>I'm having trouble getting a $scope variable to trigger the screen to rebind. Yes, I've tried calling $scope.$apply() after assigning $scope.value = value;  Yes, I've tried calling $digest() manually after the assignment; I get the error "$rootScope:inprog] $digest already in progress.</p>
  
  <p>So What I've done is try to get my $rootScope.$on('message'function(){}) listener to create a secondary $broadcast to all scopes to try and get to the bottom of this; however, my $scope's registration of the event is not firing and I'm thinking this might be related to the same issue....maybe not. At any rate, here's my codez.</p>
  
  <p>I'd build a fiddle but it's currently blocked by network policy.</p>
  
  <p>Manifest:</p>
  
  <ul>
  <li>[config]</li>
  <li>[index.html]</li>
  <li>[foo.html]</li>
  <li>[ctrl]</li>
  </ul>
  
  <p>[config] (a couple of attempted hacks. They're marked with comments)</p>
  
  <pre><code>    var kata = angular.module('kata',[
          'ngRoute'   
      ]).run(['$rootScope',
      function($rootScope){
          $rootScope.$on('message:foo',function(event,data){
              $rootScope.$broadcast('message:bar',['foo1','foo2','foo3']);//send secondary msg
              $rootScope.data = data; //Hack #1: When I couldn't get $scope to rebind, I tried to use $rootScope;still doesn't rebind.
          });
      }]);
  
  kata.config(['$routeProvider',
      function($routeProvider){
          $routeProvider
              .when('/Foo',{
                  templateUrl: 'foo.html',
                  controller: 'FooCtrl'
              });
  }]);
  </code></pre>
  
  <p>[index] (nothing funny here)</p>
  
  <pre><code>&lt;html ng-app="kata"&gt;
      &lt;head&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"&gt;&lt;/meta&gt;
          &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.js"&gt;&lt;/script&gt;
          &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"&gt;&lt;/script&gt;
  
          &lt;script src="./routingConfig.js"&gt;&lt;/script&gt;
          &lt;script src="./controllers.js"&gt;&lt;/script&gt;        
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div class="view-container"&gt;
              &lt;div ng-view class="view-frame"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>[foo.html] (nothing funny here)
  A couple of tests with a couple of $scope variables attached to same stuff.
  Neither of these update</p>
  
  <pre><code>&lt;div&gt;
      This page is for capturing Data
  
      Data: {{data}}
      &lt;hr /&gt;
      &lt;ul&gt;
          &lt;li ng-repeat="foo in foos"&gt;
              &lt;span&gt;Foo Found!&lt;/span&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>[ctrl] (created several variables on scope trying to attack this problem in different ways)</p>
  
  <pre><code>var kataCtrl= kata.controller("FooCtrl", 
      [        '$scope', '$http','$rootScope','$location'
      ,function($scope,   $http,  $rootScope , $location) {
          $scope.data = "Foo";
          $scope.data1 = "[placeholder]";
          $scope.foos = [];
  
  
          //fires, assigns, view does not update
          $scope.$watch(function(){
              return $rootScope.data;
          }, function(){
              $scope.foos = ['data','foo','bar','baz'];&lt;=Assignment succeeds. View does not update
              $scope.$apply();//&lt;=Does nothing apparent; View does not update
              $scope.$digest();//&lt;= Console Error. Already in digest loop
          },true);
  
  
          //does not fire
          $scope.$on('message:foo',function(event,data){ //&lt;= This never catches
              $scope.data = data; 
          });
  
  
          //fires, assigns, View does not update
          $rootScope.$on('message:bar',function(event,data){
              $scope.foos = ['data','foo','bar','baz'];
              $scope.foo1 = data.element1;
              $scope.data = "[Foos returned from $rootScope]";
              $scope.$apply();//&lt;= Does not help. Changing to $scope.$digest() indicates already in digest loop
          });
  }]);
  </code></pre>
  
  <p>So as a recap, $rootScope.$on() inside my config is firing.  It is assigning values to variables on $rootScope properly.  $rootScope.$broadcast is generating a secondary message.  The controller's $scope.$on registration of the message does not catch.The controller's $rootScope.$on registration fires and assigns values on $scope, but the view does not rebind.  Calling $scope.$apply() does not help.  Calling $scope.$digest() merely reports that a digest loop is currently running.  </p>
  
  <p>Scoped variables are assigned to but the view never rebinds. </p>
  
  <p>What in the wide wide world of sports is going on here?</p>