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

Commit 6a73d5b

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 0694af8 commit 6a73d5b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ngRoute/route.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ function $RouteProvider() {
350350
'$injector',
351351
'$templateRequest',
352352
'$sce',
353-
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) {
353+
'$browser',
354+
function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce, $browser) {
354355

355356
/**
356357
* @ngdoc service
@@ -776,6 +777,7 @@ function $RouteProvider() {
776777

777778
function resolveLocals(route) {
778779
if (route) {
780+
$browser.$$incOutstandingRequestCount();
779781
var locals = angular.extend({}, route.resolve);
780782
angular.forEach(locals, function(value, key) {
781783
locals[key] = angular.isString(value) ?
@@ -786,7 +788,10 @@ function $RouteProvider() {
786788
if (angular.isDefined(template)) {
787789
locals['$template'] = template;
788790
}
789-
return $q.all(locals);
791+
return $q.all(locals).then(function(locals) {
792+
$browser.$$completeOutstandingRequest(function() {});
793+
return locals;
794+
});
790795
}
791796
}
792797

0 commit comments

Comments
 (0)