Creates a new UIRouter instance
Creates a new UIRouter instance
This can be used to manually bootstrap the router.
import { UIRouterReact } from "ui-router-ng2";
let routerInstance = new UIRouterReact();
routerInstance.start();
Global router state
a LocationConfig implementation
a LocationServices implementation
Provides a registry for states, and related registration services
Provides services related to states
Provides trace information to the console
Provides services related to Transitions
Deprecated for public use. Use urlService instead.
Deprecated for public use. Use urlService instead.
Provides services related to the URL
Provides services related to ui-view synchronization
Registers an object to be notified when the router is disposed
Registers an object to be notified when the router is disposed
Disposes this router instance
Disposes this router instance
When called, clears resources retained by the router by calling dispose(this)
on all
registered disposable objects.
Or, if a disposable
object is provided, calls dispose(this)
on that object only.
(optional) the disposable to dispose
Returns registered plugins
Returns registered plugins
Returns the registered plugin of the given pluginName
.
If no pluginName
is given, returns all registered plugins
the named plugin (undefined if not found), or all plugins (if pluginName
is omitted)
Add plugin (as ES6 class)
Add plugin (as javascript constructor function)
Add plugin (as javascript factory function)
Add plugin (as ES6 class)
This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.
import { MyCoolPlugin } from "ui-router-cool-plugin";
var plugin = router.addPlugin(MyCoolPlugin);
A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.
The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.
The plugin can then be published as a separate module.
export class MyAuthPlugin implements UIRouterPlugin {
constructor(router: UIRouter, options: any) {
this.name = "MyAuthPlugin";
let $transitions = router.transitionService;
let $state = router.stateService;
let authCriteria = {
to: (state) => state.data && state.data.requiresAuth
};
function authHook(transition: Transition) {
let authService = transition.injector().get('AuthService');
if (!authService.isAuthenticated()) {
return $state.target('login');
}
}
$transitions.onStart(authCriteria, authHook);
}
}
one of:
- a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
- a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
- a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance
options to pass to the plugin class/factory
the registered plugin instance
Add plugin (as javascript constructor function)
This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.
import { MyCoolPlugin } from "ui-router-cool-plugin";
var plugin = router.addPlugin(MyCoolPlugin);
A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.
The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.
The plugin can then be published as a separate module.
export class MyAuthPlugin implements UIRouterPlugin {
constructor(router: UIRouter, options: any) {
this.name = "MyAuthPlugin";
let $transitions = router.transitionService;
let $state = router.stateService;
let authCriteria = {
to: (state) => state.data && state.data.requiresAuth
};
function authHook(transition: Transition) {
let authService = transition.injector().get('AuthService');
if (!authService.isAuthenticated()) {
return $state.target('login');
}
}
$transitions.onStart(authCriteria, authHook);
}
}
one of:
- a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
- a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
- a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance
options to pass to the plugin class/factory
the registered plugin instance
Add plugin (as javascript factory function)
This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.
import { MyCoolPlugin } from "ui-router-cool-plugin";
var plugin = router.addPlugin(MyCoolPlugin);
A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.
The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.
The plugin can then be published as a separate module.
export class MyAuthPlugin implements UIRouterPlugin {
constructor(router: UIRouter, options: any) {
this.name = "MyAuthPlugin";
let $transitions = router.transitionService;
let $state = router.stateService;
let authCriteria = {
to: (state) => state.data && state.data.requiresAuth
};
function authHook(transition: Transition) {
let authService = transition.injector().get('AuthService');
if (!authService.isAuthenticated()) {
return $state.target('login');
}
}
$transitions.onStart(authCriteria, authHook);
}
}
one of:
- a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
- a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
- a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance
options to pass to the plugin class/factory
the registered plugin instance
Starts the router
Starts the router
Calling this method enables listening to the URL for changes. It also performs the initial state synchronization from the URL.
Generated using TypeDoc
The main UIRouter object
This is the main UIRouter object. There should be one instance of this object per running application.
This class has references to all the other UIRouter services.