diff --git a/angular-ui/angular-ui-router-tests.ts b/angular-ui/angular-ui-router-tests.ts index 38f8b5ca0..5a9c4ad6c 100644 --- a/angular-ui/angular-ui-router-tests.ts +++ b/angular-ui/angular-ui-router-tests.ts @@ -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" } } }); -}); \ No newline at end of file +}); diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index bc3e27c2d..da3d92e5e 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -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 {