
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@uirouter/visualizer
Advanced tools
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)
The Visualizer is a UI-Router plugin.
Register the plugin with the UIRouter
object.
Using a <script>
tag
Add the script as a tag in your HTML.
<script src="//unpkg.com/@uirouter/visualizer@4"></script>
The visualizer Plugin can be found (as a global variable) on the window object.
var Visualizer = window['@uirouter/visualizer'].Visualizer;
Using require
or import
(SystemJS, Webpack, etc)
Add the npm package to your project
npm install @uirouter/visualizer
require
or ES6 import
:var Visualizer = require('@uirouter/visualizer').Visualizer;
import { Visualizer } from '@uirouter/visualizer';
First get a reference to the UIRouter
object instance.
This differs by framework (AngularJS, Angular, React, etc. See below for details).
After getting a reference to the UIRouter
object, register the Visualizer
plugin
var pluginInstance = uiRouterInstance.plugin(Visualizer);
You can pass a configuration object when registering the plugin. The configuration object may have the following fields:
state
: (boolean) State Visualizer is not rendered when this is false
transition
: (boolean) Transition Visualizer is not rendered when this is false
stateVisualizer.node.label
: (function) A function that returns the label for a nodestateVisualizer.node.classes
: (function) A function that returns classnames to apply to a nodestateVisualizer.node.label
The labels for tree nodes can be customized.
Provide a function that accepts the node object and the default label and returns a string:
function(node, defaultLabel) { return "label"; }
This example adds (future)
to future states.
Note: node.self
contains a reference to the state declaration object.
var options = {
stateVisualizer: {
node: {
label: function (node, defaultLabel) {
return node.self.name.endsWith('.**') ? defaultLabel + ' (future)' : defaultLabel;
},
},
},
};
var pluginInstance = uiRouterInstance.plugin(Visualizer, options);
stateVisualizer.node.classes
The state tree visualizer can be configured to add additional classes to nodes.
Example below marks every node with angular.js view with is-ng1
class.
var options = {
stateVisualizer: {
node: {
classes(node) {
return Object.entries(node.views || {}).some((routeView) => routeView[1] && routeView[1].$type === 'ng1')
? 'is-ng1'
: '';
},
},
},
};
var pluginInstance = uiRouterInstance.plugin(Visualizer, options);
UIRouter
objectInject the $uiRouter
router instance in a run block.
// inject the router instance into a `run` block by name
app.run(function ($uiRouter) {
var pluginInstance = $uiRouter.plugin(Visualizer);
});
Use a config function in your root module's UIRouterModule.forRoot()
.
The router instance is passed to the config function.
import { Visualizer } from "@uirouter/visualizer";
...
export function configRouter(router: UIRouter) {
var pluginInstance = router.plugin(Visualizer);
}
...
@NgModule({
imports: [ UIRouterModule.forRoot({ config: configRouter }) ]
...
Create the UI-Router instance manually by calling new UIRouterReact();
var Visualizer = require('@uirouter/visualizer').Visualizer;
var router = new UIRouterReact();
var pluginInstance = router.plugin(Visualizer);
Add the plugin to your UIRouter
component
var Visualizer = require('@uirouter/visualizer').Visualizer;
...
render() {
return <UIRouter plugins=[Visualizer]></UIRouter>
}
7.2.1 (2020-09-19)
Compare @uirouter/visualizer
versions 7.2.0 and 7.2.1
Compare @uirouter/visualizer
versions 7.1.0 and 7.2.0
FAQs
UI-Router State Visualizer and Transition Visualizer
The npm package @uirouter/visualizer receives a total of 5,615 weekly downloads. As such, @uirouter/visualizer popularity was classified as popular.
We found that @uirouter/visualizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.