title: Unable to update the rootScope in angular
body: <p>I am trying to send a request to a php file from one controller in angular and getting the response. I stored the response in a rootScope variable which is initialized in the controller.run() method with 0.</p>
  
  <p>Now I am trying to use the updated rootScope in another controller in order to display the response from the php page. But the rootScope is not getting updated and it is still showing 0.</p>
  
  <p>Here is my code.</p>
  
  <p>The following is the run method where the rootScope is initialized</p>
  
  <pre><code>adminController.run(function ($rootScope) {
      $rootScope.n = 0;
  });
  </code></pre>
  
  <p>The following is the code for controller 1 where I am requesting a response from the php page and updating the rootScope variable.</p>
  
  <pre><code>adminController.controller('adminLoginController', function($scope,$rootScope,$http,$window) {
  
      $scope.loginCheck = function(event,user){
          var request = $http({
              method: "post",
              url: "../_/php/loginCheck.php",
              headers: { 'Content-Type': 'application/x-www-form-urlencoded'     }
          });
          request.success(function (data) {
              $rootScope.n=data;
              $rootScope.$apply();
              $window.location.href = 'admin.html#admin_home';       
          });
      }
  });
  </code></pre>
  
  <p>Here is the code for my second controller where I am utilizing the rootScope variable. Here the problem comes as the rootScope is not getting updated and displaying me only the 0 with which it is initialized.</p>
  
  <pre><code>adminController.controller('adminHomeController', function($scope,$rootScope,$http,$window) {
      $scope.uname=$rootScope.n;
      alert($scope.uname);
  });
  </code></pre>
  
  <p>Can some one let me know where I am going wrong.</p>