ui-router
Version:
State-based routing for Javascript
48 lines (36 loc) • 1.92 kB
text/typescript
/** @module core */ /** */
import {UrlMatcherFactory} from "./url/urlMatcherFactory";
import {UrlRouterProvider} from "./url/urlRouter";
import {StateProvider} from "./state/state";
import {UrlRouter} from "./url/urlRouter";
import {TransitionService} from "./transition/transitionService";
import {ViewService} from "./view/view";
import {StateRegistry} from "./state/stateRegistry";
import {StateService} from "./state/stateService";
import {UIRouterGlobals} from "./globals";
/**
* The master class used to instantiate an instance of UI-Router.
*
* This class instantiates and wires the global UI-Router services.
*
* After instantiating a new instance of the Router class, configure it for your app. For instance, register
* your app states with the [[stateRegistry]] (and set url options using ...). Then, tell UI-Router to monitor
* the URL by calling `urlRouter.listen()` ([[URLRouter.listen]])
*/
export class UIRouter {
viewService = new ViewService();
transitionService: TransitionService = new TransitionService(this.viewService);
globals: UIRouterGlobals = new UIRouterGlobals(this.transitionService);
urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory();
urlRouterProvider: UrlRouterProvider = new UrlRouterProvider(this.urlMatcherFactory, this.globals.params);
urlRouter: UrlRouter = new UrlRouter(this.urlRouterProvider);
stateRegistry: StateRegistry = new StateRegistry(this.urlMatcherFactory, this.urlRouterProvider);
/** @hidden TODO: move this to ng1.ts */
stateProvider = new StateProvider(this.stateRegistry);
stateService = new StateService(this.viewService, this.urlRouter, this.transitionService, this.stateRegistry, this.stateProvider, this.globals);
constructor() {
this.viewService.rootContext(this.stateRegistry.root());
this.globals.$current = this.stateRegistry.root();
this.globals.current = this.globals.$current.self;
}
}