1.0.0-alpha.1
Pre-release(2016-03-27) diff
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)angular-ui-router
(npm and bower)ui-router-ng2
(npm; coming soon, in 1.0.0-alpha.2)
The ui-router-core
package is framework-agnostic. Both ng1 and ng2 packages share the code in ui-router-core
and provide viewport adapters to implement the <ui-view>
. Third parties could potentially depend on ui-router-core
to 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's bindings:
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 of bindings: { foo: '<' }
, we will map to scope: { 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 onExit
can 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's routerCanDeactivate
. See the Ng1Controller docs for more information. The uiCanExit
view 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 callback uiOnParamsChanged
may 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 .parent
or .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:
var normalState = $state.get('foo');
var internalStateObject = normalState.$$state();
console.log(internalStateObject.parent.name);
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.
Bug fixes and features since 1.0.0alpha0
Bug Fixes
- date: Compare dates only using year, month, date (7a68ade), closes #2484
- params: Clone all properties of a Node. Introduce applyRawParams() (88c624d)
- RejectFactory: stringify rejections with circular dependency-aware stringify (199db79), closes #2538
- src/resolve: use injector's strictDi value in calls to .annotate (4c5b5d8)
- stateQueueManager: Use
location: true
for url-matched transitions (25e0c04), closes #2455 - stateService: Process reload: in the StateService.target() (081da32), closes #2537
- Transition: Do not reuse resolves for reloaded state during redirect (0c123c3), closes #2539
- Transition: Reject Transition promise when onBefore error (4b6d56f), closes #2561
- Transition: Reset URL to current state after aborted transition (3a1308b), closes #2611
- transition/transitionService: uses console.error to log error in default error handler (43a8fc5)
- ui-sref: update ui-sref-active/eq info when params change (dcbaebf), closes #2554
- ui-state: update ui-sref-active/eq info (025ebc8), closes #2488
- UrlMatcher: Format parent/child UrlMatchers properly (86e07ef), closes ##2504
- UrlMatcher: isOptional always false for empty parameter (4e85db4)
Features
- params: Add uiOnParamsChanged controller callback (961c96d), closes #2608 #2470 #2391 #1967
- resolve: Allow all resolved data for a node to be injected as
$resolve$
(e432c27) - state: Expose the internal state API via
$$state()
(92053f1), closes #13 - ui-router-ng2: Initial angular2 support (217de70)
- uiCanExit: Add controller lifecycle hook "uiCanExit" (afcfe95)
- uiView: Expose the resolved data for a state as $scope.$resolve (0f6aea6), closes #2175 #2547
- uiView: Fire the $onInit hook (c8afc38), closes #2559
- uiView: Put $animate promises on element.data('$uiView') (a5578de), closes #2562 #2579
- view: Route a view to a directive using
component:
(1552032), closes #2627
Other commits
Many of these commits are merged from 0.2.x legacy
branch
- uiSrefActive: allow multiple classes (120d7ad), closes #2481 #2482
- justjs: provide naive implementation of most of the coreservices api (426f134)
- resolve: add $resolve service back to 1.0 (70c6659)
- uiSrefActive: allow active & active-eq on same element (d9a676b), closes #1997
- uiSrefActive: provide a ng-{class,style} like interface (a9ff6fe), closes #1431
- uiSrefActive: Added support for multiple nested uiSref directives (b184494)
- uiState: add ui-state directive (3831af1), closes #395 #900 #1932
- urlMatcher: add support for optional spaces (4b7f304)
- urlMatcher: Add param only type names (6a371f9)
- $IncludedByStateFilter: add parameters to $IncludedByStateFilter (963f6e7), closes #1735
- $state: make state data inheritance prototypical (c4fec8c)
- $state: Inject templateProvider with resolved values (afa20f2)
- $state: added 'state' to state reload method (feat no.1612) (b8f0457)
- $state: broadcast $stateChangeCancel event when event.preventDefault() is called in $sta (ecefb75)
- $state: inject resolve params into controllerProvider (b380c22), closes #1131
- $state: support URLs with #fragments (3da0a17)
- $uiViewScroll: change function to return promise (c2a9a31), closes #1702