title: angularJS $broadcast and $on
body: <p>is there a way to make the $broadcast propagate the variable to the $on during initialization phase?</p>
  
  <pre><code>&lt;div ng-app='test'&gt;
      &lt;div ng-controller='testCtrl'&gt; &lt;span&gt;{{testContent}}&lt;/span&gt; 
      &lt;/div&gt;
      &lt;div ng-controller="testCtrl2"&gt;
          &lt;input type='text' ng-change="updateContent()" ng-model="testContent2" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>var app = angular.module('test', []);
  app.factory('sharedContent', function ($rootScope) {
      var standardContent;
      var resizeProportion;
      return {
          setStandardContent: function (newStandardContent) {
              standardContent = newStandardContent;
              $rootScope.$broadcast('updateContent');
              console.log('broadcast');
          },
          getStandardContent: function () {
              return standardContent;
          },
          setResizeProportion: function (newResizeProportion) {
              $rootScope.$broadcast('updateResizeProportion');
          },
      }
  });
  app.run(function (sharedContent) {
      sharedContent.setStandardContent('haha');
  });
  
  function testCtrl($scope, sharedContent) {
      $scope.testContent;
      $scope.$on('updateContent', function () {
          console.log('receive');
          $scope.testContent = sharedContent.getStandardContent();
      });
  }
  
  function testCtrl2($scope, sharedContent) {
      $scope.testContent2 = 'test';
      $scope.updateContent = function () {
          sharedContent.setStandardContent($scope.testContent2);
      };
  }
  </code></pre>
  
  <p>Sample fiddle : <a href="http://jsfiddle.net/jiaming/NsVPe/" rel="noreferrer">http://jsfiddle.net/jiaming/NsVPe/</a></p>
  
  <p>The span will display the value as the input changes, which is due to the ng-change function.</p>
  
  <p>However, at initialization phase, the value "haha" was not propagated to the $scope.testContent and thus, nothing was shown at first runtime. Is there a way to make the value "haha" appear at the first runtime?</p>
  
  <p>Thank you.</p>