An object that contains global router state, such as the current state and params
a LocationConfig implementation
a LocationServices implementation
Provides a registry for states, and related registration services
Provides services related to states
Enable/disable tracing to the javascript console
A service that exposes global Transition Hooks
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
Returns a plugin registered with the given pluginName
.
the name of the plugin to get
the plugin, or undefined
Returns all registered plugins
all registered plugins
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 UIRouterPlugin - a constructor function for a UIRouterPlugin which accepts a UIRouter instance - a factory function which accepts a UIRouter instance and returns a UIRouterPlugin 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);
}
}
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);
}
}
the registered plugin instance
Generated using TypeDoc
An instance of UI-Router.
This object contains references to service APIs which define your application's routing behavior.