title: $rootScope.$broadcast not working
body: <p>I am trying to get $rootScope.$broadcast to refresh my view. 
  The service is- </p>
  
  <pre><code>var app = angular.module("productsApp", [])
      .service("serviceProvider", function ($http) {
          this.getDatas = function getDatas(data) {
              return $http({
                  method: 'POST', url: serviceUrl + '/GetProductsByCategoryOrName', headers: {
                      'Authorization': apiKey
                  },
                  data: data
              })
          }
          return this
      }).factory("sharedService", function ($rootScope) {
  
          var mySharedService = {};
  
          mySharedService.values = [];
  
          mySharedService.passData = function (newData) {
              mySharedService.values = newData;
              $rootScope.$broadcast('dataPassed', newData);
          }
  
          return mySharedService;
      });
  </code></pre>
  
  <p><strong>Invoking through controller-</strong></p>
  
  <pre><code>function searchProductsController($scope, $window, serviceProvider, sharedService) {
      $scope.submit = function () {
          var data = { "query": $scope.searchText, "categoryId": "976759", "pageIndex": 0, "sortDirection": "asc" };
          serviceProvider.getDatas(data).then(function (response) {
              var result = response;
              sharedService.passData(result.data.data);
          });
      }
  };
  </code></pre>
  
  <p>here in this controller <code>sharedService.passData</code> which passes new array to service method. Then it is trying to broadcast it for the changes with the line-  <code>$rootScope.$broadcast('dataPassed', newData)</code></p>
  
  <p>I don't know why it is not broadcasting the changes to view. Is there any other way to broadcast the changes?</p>
  
  <p><strong>Note-</strong>
  My earlier question <a href="https://stackoverflow.com/questions/35624113/how-to-transfer-data-between-controllers/35624161?noredirect=1#comment58931805_35624161">How to transfer data between controllers</a> couldn't get me any help.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So far I've changed in the listeners- </p>
  
  <pre><code>mySharedService.passData = function (newData) {
      $rootScope.$broadcast('dataPassed', newData)
  }
  $rootScope.$on('dataPassed', function (newData) {
      mySharedService.values = newData;
  })
  </code></pre>
  
  <p>But still can't get refreshed view.</p>