mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-07 23:17:02 +08:00
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:
committed by
Brian Ford
parent
719c747cd8
commit
3b5d75c021
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user