Javascript $http.get()触发$locationChangeSuccess事件?

Javascript $http.get()触发$locationChangeSuccess事件?,javascript,angularjs,xmlhttprequest,Javascript,Angularjs,Xmlhttprequest,我的理解是,该服务围绕浏览器的XMLHttpRequest提供异步调用功能。但是,当我将$http与$location一起使用时,我发现在请求生成成功响应时,调用$http.get()也会触发$locationChangeSuccess 为什么会这样?由于浏览器中的URL没有更改,我不希望触发$locationChangeSuccess事件。这个例子说明了这个问题 angular.module('fiddle', []) .controller('MainController', ['$sc

我的理解是,该服务围绕浏览器的XMLHttpRequest提供异步调用功能。但是,当我将
$http
$location
一起使用时,我发现在请求生成成功响应时,调用
$http.get()
也会触发
$locationChangeSuccess

为什么会这样?由于浏览器中的URL没有更改,我不希望触发
$locationChangeSuccess
事件。这个例子说明了这个问题

angular.module('fiddle', [])
  .controller('MainController', ['$scope', '$http', '$location'
    function($scope, $http, $location) {
      $scope.numberOfLocationChanges = 0;

      // Constructor
      $scope.__init__ = function() {            
        $http.get('/').then(
          function success(response) {
            console.log('success: %o', response);
          },
          function error(response) {
            console.log('error: %o', response);
          }
        );
      };

      $scope.handleLocationChangeSuccess = function() {
        $scope.numberOfLocationChanges++;
      };

      // Bind event handlers
      $scope.$on('$locationChangeSuccess',
        $scope.handleLocationChangeSuccess);

      // Call the constructor
      $scope.__init__();
    }
  ]);
如果有问题,在删除
$location
服务后,
$locationChangeSuccess
将不再触发