feat(ngRoute): alias string as redirectTo property in .otherwise()

Allow `.otherwise()` to interpret a string parameter
as the `redirectTo` property

Closes #7794
This commit is contained in:
Erin Altenhof-Long
2014-06-12 12:01:29 -07:00
committed by Brian Ford
parent 719c747cd8
commit 3b5d75c021
2 changed files with 22 additions and 1 deletions

View File

@@ -460,6 +460,23 @@ describe('$route', function() {
expect(onChangeSpy).toHaveBeenCalled();
});
});
it('should interpret a string as a redirect route', function() {
module(function($routeProvider) {
$routeProvider.when('/foo', {templateUrl: 'foo.html'});
$routeProvider.when('/baz', {templateUrl: 'baz.html'});
$routeProvider.otherwise('/foo');
});
inject(function($route, $location, $rootScope) {
$location.path('/unknownRoute');
$rootScope.$digest();
expect($location.path()).toBe('/foo');
expect($route.current.templateUrl).toBe('foo.html');
});
});
});