1 // Type definitions for Angular JS 1.1.5+ (ui.router module)
2 // Project: https://github.com/angular-ui/ui-router
3 // Definitions by: Michel Salib <https://github.com/michelsalib>
4 // Definitions: https://github.com/borisyankov/DefinitelyTyped
11 templateUrl?: any; // string || () => string
12 templateProvider?: any; // () => string || IPromise<string>
14 controllerAs?: string;
15 controllerProvider?: any;
21 onEnter?: (...args: any[]) => void;
22 onExit?: (...args: any[]) => void;
24 reloadOnSearch?: boolean;
27 interface ITypedState<T> extends IState {
31 interface IStateProvider extends IServiceProvider {
32 state(name: string, config: IState): IStateProvider;
33 state(config: IState): IStateProvider;
34 decorator(name?: string, decorator?: (state: IState, parent: Function) => any): any;
37 interface IUrlMatcher {
38 concat(pattern: string): IUrlMatcher;
39 exec(path: string, searchParams: {}): {};
40 parameters(): string[];
41 format(values: {}): string;
44 interface IUrlMatcherFactory {
45 compile(pattern: string): IUrlMatcher;
46 isMatcher(o: any): boolean;
49 interface IUrlRouterProvider extends IServiceProvider {
50 when(whenPath: RegExp, handler: Function): IUrlRouterProvider;
51 when(whenPath: RegExp, handler: any[]): IUrlRouterProvider;
52 when(whenPath: RegExp, toPath: string): IUrlRouterProvider;
53 when(whenPath: IUrlMatcher, hanlder: Function): IUrlRouterProvider;
54 when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider;
55 when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider;
56 when(whenPath: string, handler: Function): IUrlRouterProvider;
57 when(whenPath: string, handler: any[]): IUrlRouterProvider;
58 when(whenPath: string, toPath: string): IUrlRouterProvider;
59 otherwise(handler: Function): IUrlRouterProvider;
60 otherwise(handler: any[]): IUrlRouterProvider;
61 otherwise(path: string): IUrlRouterProvider;
62 rule(handler: Function): IUrlRouterProvider;
63 rule(handler: any[]): IUrlRouterProvider;
66 interface IStateOptions {
74 interface IHrefOptions {
81 interface IStateService {
82 go(to: string, params?: {}, options?: IStateOptions): IPromise<any>;
83 transitionTo(state: string, params?: {}, updateLocation?: boolean): void;
84 transitionTo(state: string, params?: {}, options?: IStateOptions): void;
85 includes(state: string, params?: {}): boolean;
86 is(state:string, params?: {}): boolean;
87 is(state: IState, params?: {}): boolean;
88 href(state: IState, params?: {}, options?: IHrefOptions): string;
89 href(state: string, params?: {}, options?: IHrefOptions): string;
90 get(state: string): IState;
97 interface IStateParamsService {
101 interface IStateParams {
105 interface IUrlRouterService {
107 * Triggers an update; the same update that happens when the address bar
108 * url changes, aka $locationChangeSuccess.
110 * This method is useful when you need to use preventDefault() on the
111 * $locationChangeSuccess event, perform some custom logic (route protection,
112 * auth, config, redirection, etc) and then finally proceed with the transition
113 * by calling $urlRouter.sync().
119 interface IUiViewScrollProvider {
121 * Reverts back to using the core $anchorScroll service for scrolling
122 * based on the url anchor.
124 useAnchorScroll(): void;