UI-Router 1.0 beta release
(2016-06-30) diff
UI-Router has a new home
BREAKING CHANGES
These breaking changes are for users upgrading from a 1.0 alpha, not for those upgrading from the 0.x legacy series.
This list is extensive, but typical users won't be affected by most of these changes.
The most common breaks will be #1 and #2
- BC-BREAK: renamed all Ui* (lowercase 'i') symbols to UI* (uppercase 'I') for more consistent naming.
- UiView -> UIView
- UiSref -> UISref (and related directives)
- UiInjector -> UIInjector
-
BC-BREAK: Transition Hooks are no longer injected (
onBefore/onStart/onExit/onRetain/onEnter/onFinish/onSuccess/onError
)Previously, a hook like
['$state', ($state) => $state.target('foo')]
would get the$state
service injected.Now, all hooks receive two parameters:
-
transition
: the currentTransition
, which has aninjector()
function -
state
: foronEnter/onRetain/onExit
hooks only, theState
which the hook is being run for. This value will benull
foronBefore/onStart/onFinish/onSuccess/onError
hooks.Refactor your hooks:
-
from:
['$state', 'mySvc', ($state, mySvc) => mySvc.foo() ? $state.target('foo')] : true
-
to:
(trans) => trans.injector().get('mySvc').foo() ? trans.router.stateService.target('foo') : true
Note: for backwards compatiblity, angular 1
onEnter/onExit/onRetain
hooks declared on a state object are still injected
- BC-BREAK: Removed
Transition.resolves()
in favor ofTransition.getResolveValue(token)
andTransition.getResolveTokens()
This change is necessary to support injection tokens of arbitrary types, not just strings.
-
BC-BREAK: - The (internal API) State object's .resolve property is now an array of Resolvables, built from state definitions by the StateBuilder. This object is an internal representation, and not generally accessed by end users.
-
BC-BREAK: - Removed the default resolve called
$resolve$
, which was added in a previous alpha. -
BC-BREAK: -
Transition.addResolves()
replaced withTransition.addResolvable()
-
BC-BREAK: remove
ResolveContext.getResolvables()
in favor of.getToken()``and
.getResolvable()` -
BC-BREAK: remove
ResolveContext.invokeLater()
and.invokeNow()
-
BC-BREAK: remove support for
JIT
resolves. This also eliminated the need for theloadAllControllerLocals
hook which was also removed
- Previously, a resolve would be fetched "just in time", if it was injected into a transition hook. This allowed you to inject even a LAZY resolve in an `onStart` hook (a LAZY resolve is normally fetched during the `onEnter` phase).
- Since hooks are no longer injected, you have to explicitly tell a resolvable to fetch if you want to use it before its fetch lifecycle. This will be possible in beta.2 which will introduce `transition.getResolvable()`
```
transitionService.onStart({}, function(transition) {
return transition.getResolvable('foo').get().then(foo => {
// do something with resolve value
});
});
```
-
BC-BREAK: Replaced
ViewConfig.node
withViewConfig.path
. Angular 1's$(element).data('$uiView')
is affected.
Previously the .node was the node for the view. Now the last element in the path is the node for the view. -
BC-BREAK: Nodes no longer have (stateful)
.resolveContext
properties. Instead, a new ResolveContext is wrapped over a Path of Nodes when needed. RemovedPathFactory.bindResolveContexts()
. -
BC-BREAK: ResolveContext.resolvePath returns a promise for resolved data as an array of tuples, instead of a promise for an object of resolved data. Removed
ResolveContext.resolvePathElement()
. -
BC-BREAK: Removed ResolvePolicy enum in favor of the ResolvePolicy interface
{ when: "", async: "" }
-
BC-BREAK: renamed
ResolveContext.isolateRootTo
tosubContext
-
BC-BREAK: rename
UIRouterGlobals
class toGlobals
; addUIRouterGlobals
back as an interface -
BC-BREAK: Moved
defaultErrorHandler
fromTransitionService
toStateService
Features
- Resolve: Switch state.resolve to be an array of Resolvables (6743a60)
- Resolve: support ng2-like provide object literals. Support injection of arbitrary tokens, not just strings. (a7e5ea6)
- Resolve: support ng2-like provide object literals (a7e5ea6)
- Transition: expose the current
UiRouter
object as a public property (52f1308) - redirectTo: Process
redirectTo
property of a state as a redirect string/object/hook function (6becb12), closes #27 #948 - rejectFactory: separate transition aborted and transition errored reject types (55995fd)
- ParamType: allow a custom parameter Type to specify a default value for a parameter's
dynamic
property - Resolvable: Added a new Resolve Policy 'RXWAIT'. If an Observable is returned, pass the observable as the value, but also wait for it to emit its first value
Bug Fixes
- ng2.pushState: Properly match urls when base path set (b9be2dc), closes #2745
- ng2.UIRouterConfig: Allow new UIRouter() to finish before configuring it (a151f71)
- ng2.UiView: fix input resolve binding (4f53f81)
- ng2.UIView: Make routed to component appear inside UIView, not next to it. (558fc80)
- redirect: fix bug where redirected transitions with reload: true got wrong resolve values copied (bd0e3a3)
- Rejection: Silence "Error: Uncaught (in Exception)" (38432f4), closes #2676
- Trace: Fix error in console after $trace.enable() (013c77a), closes #2752
- ng2.UIView: Trigger change detection once for routed components