|
1 |
| -# feature-1.0 branch |
2 |
| -## Note: this is an alpha version of UI-Router 1.0 |
3 |
| - |
4 |
| -We've totally redesigned UI-Router under the covers (rewrote about 60% of the codebase!), separating concerns and detangling the spaghetti. We have taken some new approaches which we hope will provide unprecedented flexibility and control to your UI-Router app. |
5 |
| - |
6 |
| -We're working on a new [sample app](http://ui-router.github.io/sample-app/#/mymessages/inbox/5648b50cc586cac4aed6836f) ([Source](https://github.com/ui-router/sample-app)), as well as a [state and transition visualizer](https://github.com/ui-router/visualizer). Check them out, and give us some feedback. |
7 |
| - |
8 |
| - |
9 |
| -#### What's changed? |
10 |
| - |
11 |
| -##### Resolves |
12 |
| -The Resolve API has been rewritten from scratch. We've introduced the concept of a resolve policy, which can be one of: |
13 |
| - |
14 |
| -* EAGER: All eager resolves for a transition are resolved at the beginning, before any states are entered (this is way UI-Router 0.2.x handles resolves) |
15 |
| -* LAZY: Lazy resolves are resolved when the state they are declared on is entered. |
16 |
| -* JIT: Just-In-Time resolves do not resolve until just before they are injected into some other function. (extremely lazy) |
17 |
| - |
18 |
| -In 1.0, by default, resolves on your states are "JIT" |
19 |
| - |
20 |
| -##### Transition |
21 |
| - |
22 |
| -We've created a Transition Service to manage transitioning from one state to another. The transition service provides hooks, which you can register a callback on. The transition hooks allow you to run code at various stages of a transition, altering it as your app requires. |
23 |
| - |
24 |
| -The transition lifecycle hooks are currently: |
25 |
| - |
26 |
| -* onBefore |
27 |
| -* onStart/onInvalid |
28 |
| -* onEnter (for individual states) |
29 |
| -* onSuccess |
30 |
| -* onError |
31 |
| - |
32 |
| -When registering a hook, you can provide criteria (a state name, a glob, or a function), and you can modify the transition by returning something from the hook (an abort, a redirect, a promise, or some new resolves to add to the transition). |
33 |
| - |
34 |
| -This enables lots of fun stuff! Here are a couple of possibilities to get your imagination started: |
35 |
| -```javascript |
36 |
| -// Perform some async thing before running the transition |
37 |
| -$transitionsProvider.onBefore({ to: 'my.state', from: '*' }, function(AsyncService) { |
38 |
| - return AsyncService.doSomeAsyncThing(); |
39 |
| -}); |
40 |
| - |
41 |
| -// Add resolves to a transitoin on-the-fly |
42 |
| -$transitionsProvider.onBefore({ to: 'other.state', from: '*' }, function($transition$, AsyncService) { |
43 |
| - // someAsyncResult added as resolve to transition. It is injectable into other resolves or controllers. |
44 |
| - $transition$.addResolves({ someAsyncResult: AsyncService.doSomeAsyncThing }); |
45 |
| -}); |
46 |
| - |
47 |
| -// Declaratively protect states which require authentication; redirect to 'login' if the user is unauthenticated. |
48 |
| -$transitionsProvider.onStart({ to: function(state) { return state.requiresAuth; } }, function($transition$, $state, AuthService) { |
49 |
| - return AuthService.ensureAuthenticated().catch(function() { return $state.target("login"); }); |
50 |
| -}); |
51 |
| - |
52 |
| -// Declaratively set up default substates or other redirects; Redirect to a different target state |
53 |
| -// as declared on the original state, i.e., redirectTo: 'someotherstate' |
54 |
| -$transitionsProvider.onStart({ to: function(state) { return state.redirectTo; } }, function($transition$, $state) { |
55 |
| - return $state.target($transition$.to.redirectTo); }); |
56 |
| -}); |
57 |
| -``` |
58 |
| - |
59 |
| -##### State |
60 |
| - |
61 |
| -The $state service has been heavily refactored, and is now the primary client of the $transition service. This doesn't offer the end user much *now*, but this separation should eventually enable us to provide things like multiple simultanesouly active states and parallel transitions (think UI-Router Extras "Sticky States"). |
62 |
| - |
63 |
| -State events will soon be deprecated, but can be easily re-enabled by including the stateEvents.js file. The state events have all been refactored as callbacks to the transition hooks. |
64 |
| - |
65 |
| -##### Views |
66 |
| - |
67 |
| -The way UI-Router manages views has been heavily refactored into a view service. This should allow us to plug in alternate rendering schemes (react?), and should help ease the transition to angular 2. |
68 |
| - |
69 |
| -##### Parameters |
70 |
| - |
71 |
| -This one has been a long time coming. Finally, UI-Router supports dynamic parameters in both the URL path and query string. We've included a decorator which enables reloadOnSearch behavior using dynamic params automatically. |
72 |
| - |
73 |
| -### What's next? |
74 |
| - |
75 |
| -We're not done making sure every use case that you've been using in UI-Router 0.2.x works just as well in 1.0. In fact, we just got the new code routing again on June 25 and have no idea what gaps are out there. We'd like to get some other eyes on this new codebase. We've moved in most of the unit tests from 0.2.x, but there are certain to be some things missing. |
76 |
| - |
77 |
| -Build it. Try it. Let us know what's horribly broken. |
78 |
| - |
79 |
| -#### ES6/TypeScript |
80 |
| - |
81 |
| -We have migrated our codebase to ES6 and Typescript. |
82 |
| - |
83 |
| -#### Angular 2 |
84 |
| - |
85 |
| -We'd are going to support Angular 2. We plan to release a ui-router-ng2 around the same time ng2 final is released. |
86 |
| - |
87 |
| -#### Lazy Loading |
88 |
| - |
89 |
| -We'd like to have out-of-the-box support for lazy loading states (like UI-Router Extras "Future States") |
90 |
| - |
91 |
| ---------------------------------------------- |
92 |
| - |
93 |
| - |
94 |
| -The rest of this README is from an old release. |
95 |
| - |
96 |
| - |
97 |
| - |
98 | 1 | # AngularUI Router [](https://travis-ci.org/angular-ui/ui-router)
|
99 | 2 |
|
100 |
| -#### The de-facto solution to flexible routing with nested views |
| 3 | +#### The de-facto solution to flexible routing in angular |
101 | 4 | ---
|
102 |
| -**[Download 0.2.17](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|** |
| 5 | +**[Download stable](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|** |
103 | 6 | **[Guide](https://github.com/angular-ui/ui-router/wiki) |**
|
104 | 7 | **[API](http://angular-ui.github.io/ui-router/site) |**
|
105 |
| -**[Sample](http://angular-ui.github.com/ui-router/sample/) ([Src](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) |** |
| 8 | +**[Sample](http://ui-router.github.io/sample-app/#/mymessages) ([Src](https://github.com/ui-router/sample-app)) |** |
106 | 9 | **[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |**
|
107 | 10 | **[Resources](#resources) |**
|
108 | 11 | **[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |**
|
109 | 12 | **[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |**
|
110 | 13 | **[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |**
|
111 |
| -**[Discuss](https://groups.google.com/forum/#!categories/angular-ui/router)** |
112 | 14 |
|
113 | 15 | ---
|
114 | 16 |
|
115 |
| -*_Please help us out by testing the 1.0 alpha release!_* |
116 |
| - |
117 |
| -[1.0.0alpha0 Announcement](https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0) ([Source Code](https://github.com/angular-ui/ui-router/tree/feature-1.0)) | [Sample App](http://ui-router.github.io/sample-app/) ([Source Code](https://github.com/ui-router/sample-app)) | [Known Issues](https://github.com/angular-ui/ui-router/issues?q=is%3Aissue+is%3Aopen+label%3A1.0) |
118 |
| - |
| 17 | +Note: this is the angular1 source for UI-Router version 1.0 alpha. If you are looking for the source for UI-Router |
| 18 | +version 0.2.x, it can be found [here](https://github.com/angular-ui/ui-router/tree/legacy) |
119 | 19 |
|
120 | 20 | ---
|
121 | 21 |
|
122 |
| -AngularUI Router is a routing framework for [AngularJS](http://angularjs.org), which allows you to organize the |
123 |
| -parts of your interface into a [*state machine*](https://en.wikipedia.org/wiki/Finite-state_machine). Unlike the |
124 |
| -[`$route` service](http://docs.angularjs.org/api/ngRoute.$route) in the Angular ngRoute module, which is organized around URL |
125 |
| -routes, UI-Router is organized around [*states*](https://github.com/angular-ui/ui-router/wiki), |
126 |
| -which may optionally have routes, as well as other behavior, attached. |
127 |
| - |
128 |
| -States are bound to *named*, *nested* and *parallel views*, allowing you to powerfully manage your application's interface. |
129 |
| - |
130 |
| -Check out the sample app: http://angular-ui.github.io/ui-router/sample/ |
131 |
| - |
132 |
| -- |
133 |
| -**Note:** *UI-Router is under active development. As such, while this library is well-tested, the API may change. Consider using it in production applications only if you're comfortable following a changelog and updating your usage accordingly.* |
| 22 | +Angular UI-Router is a client-side [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application) |
| 23 | +routing framework for [AngularJS](http://angularjs.org). |
| 24 | + |
| 25 | +Routing frameworks for SPAs update the browser's URL as the user nagivates through the app. Conversely, they allows |
| 26 | +changes to the browser's URL to drive navigation through the app, thus allowing the user to create a bookmark to a |
| 27 | +location deep within the SPA. |
134 | 28 |
|
| 29 | +UI-Router applications are modeled as a hierarchical tree of states. UI-Router provides a |
| 30 | +[*state machine*](https://en.wikipedia.org/wiki/Finite-state_machine) to manage the transitions between those |
| 31 | +application states in a transaction-like manner. |
135 | 32 |
|
136 | 33 | ## Get Started
|
137 | 34 |
|
|
0 commit comments