- Notifications
You must be signed in to change notification settings - Fork60
UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps
License
ui-router/core
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
UI-Router core provides client-sideSingle Page Applicationrouting for JavaScript.This core is framework agnostic.It is used to buildUI-Router for Angular 1,UI-Router for Angular 2, andUI-Router React.
Routing frameworks for SPAs update the browser's URL as the user navigates through the app. Conversely, this allowschanges to the browser's URL to drive navigation through the app, thus allowing the user to create a bookmark to alocation deep within the SPA.
UI-Router applications are modeled as a hierarchical tree of states. UI-Router provides astate machine to manage the transitions between thoseapplication states in a transaction-like manner.
UI-Router Core provides the following features:
- State-machine based routing
- Hierarchical states
- Enter/Exit hooks
- Name based hierarchical state addressing
- Absolute, e.g.,
admin.users - Relative, e.g.,
.users
- Absolute, e.g.,
- Flexible Views
- Nested Views
- Multiple Named Views
- Flexible URLs and parameters
- Path, Query, and non-URL parameters
- Typed parameters
- Built in:
int,string,date,json - Custom: define your own encoding/decoding
- Built in:
- Optional or required parameters
- Default parameter values (optionally squashed from URL)
- Transaction-like state transitions
- Transition Lifecycle Hooks
- First class async support
Get started using one of the existing UI-Router projects:
UI-Router core can be used implement a router for any web-based component framework.There are four basic things to build for a specific component framework:
A UIView is a component which acts as a viewport for another component, defined by a state.When the state is activated, the UIView should render the state's component.
AUISref is a link (absolute, or relative) which activates a specific state and/or parameters.When theUISref is clicked, it should initiate a transition to the linked state.
When combined with aUISref, aUISrefActive toggles a CSS class on/off when itsUISref is active/inactive.
Implement framework specific bootstrap requirements, if any.For example, UI-Router for Angular 1 and Angular 2 integrates with the ng1/ng2 Dependency Injection lifecycles.On the other hand, UI-Router for React uses a simple JavaScript based bootstrap, i.e.,new UIRouterReact().start();.
This example doesn't have UIView, UISref, or anything like that.It bootstrap the router and naively manipulates the DOM when states are activated.
https://stackblitz.com/edit/ui-router-plain-javascript?file=index.js
Note: do not model your own router off this example, it is meant to show only the bare minimum.
Create an issue or contact us onGitter.
About
UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.