r/angularjs • u/ctanga • Mar 27 '16
UI-Router 1.0.0-alpha.1 released.
https://github.com/angular-ui/ui-router/releases/tag/1.0.0-alpha.15
u/jax024 Mar 28 '16
This is a huge boost to angular 1.5. This actually makes it almost as sexy as ng2 with good principles now. I love it.
1
u/mrc1897 Mar 28 '16
Working on a ~4 month old application with Angular 1.5.x. I would like to upgrade from UI Router 0.2.15 to 1.0.0A but a bit concerned that this is ... well alpha. The app hasn't launched yet so I could do the upgrade without breaking production code but I'm not sure about bringing an alpha release into an app that will see release soon. Any thoughts?
2
2
u/Xerxero Mar 28 '16
Finally. We are using 1.5 components and getting the resolve to work was kinda awkward.
-1
u/inknownis Mar 28 '16
I am new to angular' component. How much different between components and states? Seems to me they are going to be co-existing. To me, ui-route is simpler and better. This only applies to 1.x as I have not studied 2.
2
u/ctanga Mar 28 '16
A component is basically a template and a controller encapsulated as a single concept, with well-defined inputs (and outputs).
In ui-router, a state generally has one or more views. The component is the view.
3
u/ctanga Mar 27 '16 edited Mar 28 '16
1.0.0-alpha.1 (2016-03-27)
This release checkpoints the continued development of the 1.0 codebase, as we approach final release.
Notable additions in this release:
Packages
We are now publishing three separate packages using a new publishing architecture:
ui-router-core(npm) framework agnostic coreangular-ui-router(npm and bower) angular 1ui-router-ng2(npm; coming soon!) angular 2The
ui-router-corepackage is framework-agnostic. Both ng1 and ng2 packages share the code inui-router-coreand provide viewport adapters to implement the<ui-view>. Third parties could potentially depend onui-router-coreto implement ui-router adapter for any other framework.Route to component
We now support routing to angular 1.5+
.component()s in two different ways. We now put the resolved data on$scope.$resolve(or$scope[controllerAs]$resolve), so you can use Components as route templates in the same way as ngRoute.We also now allow a state's view to be specified using
component: 'MyComponent'in lieu of a controller+template. We will map resolve data to the component'sbindings:by name.See the component and bindings for more information.
We also support angular 1.3+
.component()with Todd Motto's polyfill, and even support old school angular 1.2 directives (instead ofbindings: { foo: '<' }, we will map toscope: { foo: '=' }).View hooks (component/controller hooks)
For a long time, we've advocated using the state machine to manage application lifecycle. However, using callbacks such as
onExitcan be challenging, since the answer to "can I exit this state?" often lives in the view. We've introduced some view-level callbacks that can be used to integrate controller code with the transition pipeline.The first view hook we've implemented is
uiCanExit(). This hook can be used much the same as the component router'srouterCanDeactivate. See the Ng1Controller docs for more information. TheuiCanExitview hook is simply sugar for adding a transition onBefore hook.Dynamic params
Dynamic parameters (the replacement for
reloadOnSearch) can be declared in a params block in a state definition like so:params; { fooParam: { dynamic: true } }. When a dynamic parameter changes, it does not cause the state to be reloaded. A controller/component callbackuiOnParamsChangedmay be used to be notified of parameter changes.See the Ng1Controller docs for details on the new callback.
Expose internal state object's API
We're now exposing the internal state objects via an undocumented API. This can be useful for other library authors who need access to things like
.parentor.includes. This internal API is subject to change (it hasn't changed much so far), so be careful. The internal api of an arbitrary state can be fetched like so:We will maintain a list of Known BC from 0.2.x to 1.0 final to help you upgrade to the 1.0 release.