|
1 | 1 | # feature-1.0 branch
|
2 |
| -## Note: this is a pre-alpha preview of UI-Router 1.0 |
| 2 | +## Note: this is an alpha version of UI-Router 1.0 |
3 | 3 |
|
4 | 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 | 5 |
|
| 6 | +Have a look at our new [Sample application](http://ui-router.github.io/sample-app/#/mymessages/inbox/5648b50cc586cac4aed6836f) |
| 7 | +([Source on GitHub](http://github.com/ui-router/sample-app)) |
| 8 | + |
6 | 9 | #### What's changed?
|
7 | 10 |
|
8 | 11 | ##### Resolves
|
@@ -30,23 +33,24 @@ When registering a hook, you can provide criteria (a state name, a glob, or a fu
|
30 | 33 |
|
31 | 34 | This enables lots of fun stuff! Here are a couple of possibilities to get your imagination started:
|
32 | 35 | ```javascript
|
| 36 | +// Perform some async thing before running the transition |
33 | 37 | $transitionsProvider.onBefore({ to: 'my.state', from: '*' }, function(AsyncService) {
|
34 | 38 | return AsyncService.doSomeAsyncThing();
|
35 | 39 | });
|
36 | 40 |
|
| 41 | +// Add resolves to a transitoin on-the-fly |
37 | 42 | $transitionsProvider.onBefore({ to: 'other.state', from: '*' }, function($transition$, AsyncService) {
|
38 | 43 | // someAsyncResult added as resolve to transition. It is injectable into other resolves or controllers.
|
39 | 44 | $transition$.addResolves({ someAsyncResult: AsyncService.doSomeAsyncThing });
|
40 | 45 | });
|
41 | 46 |
|
| 47 | +// Declaratively protect states which require authentication; redirect to 'login' if the user is unauthenticated. |
42 | 48 | $transitionsProvider.onStart({ to: function(state) { return state.requiresAuth; } }, function($transition$, $state, AuthService) {
|
43 | 49 | return AuthService.ensureAuthenticated().catch(function() { return $state.target("login"); });
|
44 | 50 | });
|
45 | 51 |
|
46 |
| -$transitionsProvider.onStart({ to: function(state) { return state.requiresAuth; } }, function($transition$, $state, AuthService) { |
47 |
| - return AuthService.ensureAuthenticated().catch(function() { return $state.target("login"); }); |
48 |
| -}); |
49 |
| - |
| 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' |
50 | 54 | $transitionsProvider.onStart({ to: function(state) { return state.redirectTo; } }, function($transition$, $state) {
|
51 | 55 | return $state.target($transition$.to.redirectTo); });
|
52 | 56 | });
|
@@ -74,11 +78,11 @@ Build it. Try it. Let us know what's horribly broken.
|
74 | 78 |
|
75 | 79 | #### ES6/TypeScript
|
76 | 80 |
|
77 |
| -We have plans to migrate these new classes to ES6 (for sure), and possibly Typescript. |
| 81 | +We have migrated our codebase to ES6 and Typescript. |
78 | 82 |
|
79 | 83 | #### Angular 2
|
80 | 84 |
|
81 |
| -We'd like to support Angular 2 |
| 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. |
82 | 86 |
|
83 | 87 | #### Lazy Loading
|
84 | 88 |
|
|
0 commit comments