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

Commit 75bf807

Browse files
committed
revert: "fix(ngRoute): allow ngView to be included in an asynchronously loaded template"
This reverts commit 5e37b2a. Eagerly loading `$route`, could break tests, because it might request the root or default route template (something `$httpBackend` would know nothing about). It will be re-applied for `v1.6.x`, with a breaking change notice and possibly a way to disable the feature is tests. Fixes #14337
1 parent fe1127a commit 75bf807

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

src/ngRoute/route.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
*/
1818
/* global -ngRouteModule */
1919
var ngRouteModule = angular.module('ngRoute', ['ng']).
20-
provider('$route', $RouteProvider).
21-
// Ensure `$route` will be instantiated in time to capture the initial
22-
// `$locationChangeSuccess` event. This is necessary in case `ngView` is
23-
// included in an asynchronously loaded template.
24-
run(['$route', angular.noop]),
20+
provider('$route', $RouteProvider),
2521
$routeMinErr = angular.$$minErr('ngRoute');
2622

2723
/**

test/ngRoute/directive/ngViewSpec.js

-31
Original file line numberDiff line numberDiff line change
@@ -1027,34 +1027,3 @@ describe('ngView animations', function() {
10271027
));
10281028
});
10291029
});
1030-
1031-
describe('ngView in async template', function() {
1032-
beforeEach(module('ngRoute'));
1033-
beforeEach(module(function($compileProvider, $provide, $routeProvider) {
1034-
$compileProvider.directive('asyncView', function() {
1035-
return {templateUrl: 'async-view.html'};
1036-
});
1037-
1038-
$provide.decorator('$templateRequest', function($timeout) {
1039-
return function() {
1040-
return $timeout(angular.identity, 500, false, '<ng-view></ng-view>');
1041-
};
1042-
});
1043-
1044-
$routeProvider.when('/', {template: 'Hello, world !'});
1045-
}));
1046-
1047-
1048-
it('should work correctly upon initial page load',
1049-
// Injecting `$location` here is necessary, so that it gets instantiated early
1050-
inject(function($compile, $location, $rootScope, $timeout) {
1051-
var elem = $compile('<async-view></async-view>')($rootScope);
1052-
$rootScope.$digest();
1053-
$timeout.flush(500);
1054-
1055-
expect(elem.text()).toBe('Hello, world !');
1056-
1057-
dealoc(elem);
1058-
})
1059-
);
1060-
});

test/ngRoute/routeSpec.js

-15
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@ describe('$route', function() {
2323
dealoc(element);
2424
});
2525

26-
it('should be loaded upon initial load (even if `ngView` is loaded async)', function() {
27-
module(function($routeProvider) {
28-
$routeProvider.when('/', {template: 'Hello, world !'});
29-
});
30-
31-
inject(function($location, $rootScope) {
32-
$location.path('/');
33-
$rootScope.$digest();
34-
});
35-
36-
inject(function($route) {
37-
expect($route.current).toBeDefined();
38-
});
39-
});
40-
4126
it('should allow cancellation via $locationChangeStart via $routeChangeStart', function() {
4227
module(function($routeProvider) {
4328
$routeProvider.when('/Edit', {

0 commit comments

Comments
 (0)