revert: "fix(ngRoute): allow ngView to be included in an asynchronously loaded template"

This reverts commit 5e37b2a7fd.
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
This commit is contained in:
Georgios Kalpakas
2016-04-13 14:06:34 +03:00
parent fe1127a322
commit 75bf80700e
3 changed files with 1 additions and 51 deletions
+1 -5
View File
@@ -17,11 +17,7 @@
*/
/* global -ngRouteModule */
var ngRouteModule = angular.module('ngRoute', ['ng']).
provider('$route', $RouteProvider).
// Ensure `$route` will be instantiated in time to capture the initial
// `$locationChangeSuccess` event. This is necessary in case `ngView` is
// included in an asynchronously loaded template.
run(['$route', angular.noop]),
provider('$route', $RouteProvider),
$routeMinErr = angular.$$minErr('ngRoute');
/**
-31
View File
@@ -1027,34 +1027,3 @@ describe('ngView animations', function() {
));
});
});
describe('ngView in async template', function() {
beforeEach(module('ngRoute'));
beforeEach(module(function($compileProvider, $provide, $routeProvider) {
$compileProvider.directive('asyncView', function() {
return {templateUrl: 'async-view.html'};
});
$provide.decorator('$templateRequest', function($timeout) {
return function() {
return $timeout(angular.identity, 500, false, '<ng-view></ng-view>');
};
});
$routeProvider.when('/', {template: 'Hello, world !'});
}));
it('should work correctly upon initial page load',
// Injecting `$location` here is necessary, so that it gets instantiated early
inject(function($compile, $location, $rootScope, $timeout) {
var elem = $compile('<async-view></async-view>')($rootScope);
$rootScope.$digest();
$timeout.flush(500);
expect(elem.text()).toBe('Hello, world !');
dealoc(elem);
})
);
});
-15
View File
@@ -23,21 +23,6 @@ describe('$route', function() {
dealoc(element);
});
it('should be loaded upon initial load (even if `ngView` is loaded async)', function() {
module(function($routeProvider) {
$routeProvider.when('/', {template: 'Hello, world !'});
});
inject(function($location, $rootScope) {
$location.path('/');
$rootScope.$digest();
});
inject(function($route) {
expect($route.current).toBeDefined();
});
});
it('should allow cancellation via $locationChangeStart via $routeChangeStart', function() {
module(function($routeProvider) {
$routeProvider.when('/Edit', {