Merge pull request #1637 from santialbo/patch-2

(angular-ui-router) Set `toPath` argument to any
This commit is contained in:
Igorbek
2014-01-28 09:07:14 -08:00
2 changed files with 28 additions and 8 deletions
+18 -6
View File
@@ -9,11 +9,23 @@ interface MyAppScope extends ng.IScope {
myApp.config((
$stateProvider: ng.ui.IStateProvider,
$urlRouterProvider: ng.ui.IUrlRouterProvider) => {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/state1");
//
$urlRouterProvider: ng.ui.IUrlRouterProvider,
$urlMatcherFactory: ng.ui.IUrlMatcherFactory) => {
var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1");
$urlRouterProvider
.when('/test', '/list')
.when('/test', '/list')
.when('/test', '/list')
.when(/\/test\d/, '/list')
.when(/\/test\d/, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list')
.when(/\/test\d/,['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list'])
.when(matcher, '/list')
.when(matcher, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list')
.when(matcher, ['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list'])
.otherwise("/state1");
// Now set up the states
$stateProvider
.state('state1', {
@@ -58,4 +70,4 @@ myApp.config((
"viewB": { template: "route2.viewB" }
}
});
});
});
+10 -2
View File
@@ -42,12 +42,20 @@ declare module ng.ui {
}
interface IUrlRouterProvider extends IServiceProvider {
when(whenPath: string, toPath: string): IUrlRouterProvider;
when(whenPath: RegExp, handler: Function): IUrlRouterProvider;
when(whenPath: RegExp, handler: any[]): IUrlRouterProvider;
when(whenPath: RegExp, toPath: string): IUrlRouterProvider;
when(whenPath: IUrlMatcher, hanlder: Function): IUrlRouterProvider;
when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider;
when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider;
when(whenPath: string, handler: Function): IUrlRouterProvider;
when(whenPath: string, handler: any[]): IUrlRouterProvider;
when(whenPath: string, toPath: string): IUrlRouterProvider;
otherwise(handler: Function): IUrlRouterProvider;
otherwise(handler: any[]): IUrlRouterProvider;
otherwise(path: string): IUrlRouterProvider;
otherwise(path: Function): IUrlRouterProvider;
rule(handler: Function): IUrlRouterProvider;
rule(handler: any[]): IUrlRouterProvider;
}
interface IStateOptions {