UI-Router for AngularJS (1.x)



About

UI-Router is the defacto standard for routing in AngularJS.Influenced by the core angular router$route and the Ember Router,UI-Router has become the standard choice for routing non-trivial apps in AngularJS (1.x).

Getting UI-Router

The UI-Router package is distributed usingnpm, the node package manager.

npm install --save @uirouter/angularjs

Other examples:

  • Via command line
    • Adding a specific version to your project:npm install --save @uirouter/angularjs@1.0.7
  • Fromhttp://unpkg.com via a<script> tag in your html:
    • Latest stable version:<script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.min.js"></script>
    • A specific version:<script src="//unpkg.com/@uirouter/angularjs@1.0.7/release/angular-ui-router.min.js"></script>
    • A legacy version:<script src="//unpkg.com/angular-ui-router@0.4.2/release/angular-ui-router.js"></script>
  • From bower:
    • Latest stable version:bower install angular-ui-router
    • A specific version:bower install angular-ui-router#1.0.7
    • A legacy version:bower install angular-ui-router#0.3.1

Note: bower releases are considered ‘legacy’ and are managed athttps://github.com/angular-ui/angular-ui-router-bower

Tutorials

Learn UI-Router by following our tutorials.

Sample application

TheUI-Router Sample App is a non-trivial UI-Router application.

Development

To fix a UI-Router bug, or create an enhancement, follow these steps:

The Typescript source code for UI-Router for Angular (2+) can be found athttps://github.com/angular-ui/ui-routerUI-Router for AngularJS (1.x) depends on UI-Router Core, which can be found athttps://github.com/ui-router/core

To get started:

mkdir uiroutercd uiroutergit clone https://github.com/angular-ui/ui-router angularjsgit clone https://github.com/ui-router/core corecd corenpm installnpm linknpm run buildcd ../angularjsnpm installnpm link @uirouter/corenpm run build

To create a UI-Router bundle to test a bug fix against your app, runnpm run packageYou can then runnpm link, and then runnpm link @uirouter/angularjs in your app’s directory.Your app’s npm dependency will use the local@uirouter/angularjs package that you just built.

Alternatively, bundles are also created inrelease/angular-ui-router.js.

Updated: