Try the Demo plunker
Visualizes the state tree and transitions in UI-Router 1.0+.
This script augments your app with two components:
-
State Visualizer: Your UI-Router state tree, showing the active state and its active ancestors (green nodes)
-
Transition Visualizer: A list of each transition (from one state to another)
- Color coded transition status (success/error/ignored/redirected)
- Shows which states were retained during the transition, which were exited, and which were entered.
- Shows parameter values
- Shows resolve data
This script is distributed as a UMD module. There are two ways to add this to your application:
-
Add a script tag to your HTML. Add the font-awesome stylesheet. The visualizer will be added to the window as
window['ui-router-visualizer']
.<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css" /> <script src="//npmcdn.com/ui-router-visualizer@2"></script>
-
Create the visualizer:
Inject the
ng1UIRouter
router instance in a run block. Get theui-router-visualizer
off the window and pass it the router instance.Note: in ui-router 1.0.0-beta.2 and above,
ng1UIRouter
is renamed to$uiRouter
// inject the router instance by name app.run(function(ng1UIRouter) { var vis = window['ui-router-visualizer']; vis.visualizer(ng1UIRouter); });
Get the
ui-router-visualizer
off the window. Pass the router instance to the visualizer in theconfigure
method of your UIRouterConfig.export class MyUIRouterConfig extends UIRouterConfig { configure(router) { var vis = window['ui-router-visualizer']; vis.visualizer(router); } }
Bootstrap UI-Router by calling
new UIRouterReact();
Pass the instance to the visualizer.var vis = window['ui-router-visualizer']; let router = new UIRouterReact(); // register states here // ... vis.visualizer(router); router.start();
-
Configure your bundler to load ui-router-visualizer. The visualizer will be available
'ui-router-visualizer'
. -
Create the visualizer:
Get the
ui-router-visualizer
usingrequire
or ES6import
. Inject theng1UIRouter
router instance in a run block. Provide the router instance to the visualizer.Note: in ui-router 1.0.0-beta.2 and above,
ng1UIRouter
is renamed to$uiRouter
import * as vis from 'ui-router-visualizer'; // or: var vis = require('ui-router-visualizer'); // inject the router instance by name app.run(function(ng1UIRouter) { vis.visualizer(ng1UIRouter); });
Get the
ui-router-visualizer
usingrequire
or ES6import
. Pass the router instance to the visualizer in theconfigure
method of your UIRouterConfig.import * as vis from 'ui-router-visualizer'; // or: var vis = require('ui-router-visualizer'); export class MyUIRouterConfig extends UIRouterConfig { configure(router) { vis.visualizer(router); } }
Get the
ui-router-visualizer
usingrequire
or ES6import
. Bootstrap UI-Router by callingnew UIRouterReact();
Pass the instance to the visualizer.import * as vis from 'ui-router-visualizer'; // or: var vis = require('ui-router-visualizer'); let router = new UIRouterReact(); // register states here // ... vis.visualizer(router); router.start();