Coder Social home page Coder Social logo

core's Introduction

UI-Router Core  Build Status

UI-Router core provides client-side Single Page Application routing for JavaScript. This core is framework agnostic. It is used to build UI-Router for Angular 1, UI-Router for Angular 2, and UI-Router React.

SPA Routing

Routing frameworks for SPAs update the browser's URL as the user navigates through the app. Conversely, this allows changes to the browser's URL to drive navigation through the app, thus allowing the user to create a bookmark to a location deep within the SPA.

UI-Router applications are modeled as a hierarchical tree of states. UI-Router provides a state machine to manage the transitions between those application states in a transaction-like manner.

Features

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
  • 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
    • Optional or required parameters
    • Default parameter values (optionally squashed from URL)
  • Transaction-like state transitions
    • Transition Lifecycle Hooks
    • First class async support

Get Started

Get started using one of the existing UI-Router projects:

Build your own

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:

UIView

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.

UISref (optional, but useful)

A UISref is a link (absolute, or relative) which activates a specific state and/or parameters. When the UISref is clicked, it should initiate a transition to the linked state.

UISrefActive (optional)

When combined with a UISref, a UISrefActive toggles a CSS class on/off when its UISref is active/inactive.

Integrate with your framework's bootstrap mechanism (optional)

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();.

Minimal Example

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.

Getting help

Create an issue or contact us on Gitter.

core's People

Contributors

0x-r4bbit avatar adambabik avatar alexandrbaran avatar amcdnl avatar asperry152 avatar christopherthielen avatar csvn avatar cvn avatar cyrilf avatar dependabot-support avatar dependabot[bot] avatar eddiemonge avatar fpipita avatar gigadude avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hshn avatar jeme avatar ksperling avatar nateabele avatar patrickjs avatar peterdavehello avatar philbrown avatar proloser avatar sbezkostnyi avatar scooper91 avatar timfjord avatar timkindberg avatar wesleycho avatar ysbaddaden avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.