Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 11956ba

Browse files
committed
fix(ngRoute): make route.resolve count as a pending request
Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for that code to complete before continuing. See angular/protractor#789 (comment) for details
1 parent af0574e commit 11956ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ngRoute/route.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ function $RouteProvider() {
265265
'$injector',
266266
'$templateRequest',
267267
'$sce',
268-
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) {
268+
'$browser',
269+
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce, $browser) {
269270

270271
/**
271272
* @ngdoc service
@@ -604,6 +605,7 @@ function $RouteProvider() {
604605

605606
$q.when(nextRoute).
606607
then(function() {
608+
$browser.$$incOutstandingRequestCount();
607609
if (nextRoute) {
608610
var locals = angular.extend({}, nextRoute.resolve),
609611
template, templateUrl;
@@ -633,6 +635,7 @@ function $RouteProvider() {
633635
}
634636
}).
635637
then(function(locals) {
638+
$browser.$$completeOutstandingRequest(function() {});
636639
// after route change
637640
if (nextRoute == $route.current) {
638641
if (nextRoute) {
@@ -642,6 +645,7 @@ function $RouteProvider() {
642645
$rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute);
643646
}
644647
}, function(error) {
648+
$browser.$$completeOutstandingRequest(function() {});
645649
if (nextRoute == $route.current) {
646650
$rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error);
647651
}

0 commit comments

Comments
 (0)