1.0.0-rc.1 Release Candidate

@christopherthielen christopherthielen released this Jan 9, 2017 · 9 commits to master since this release

This is the first release candidate of angular-ui-router. Note: ui-router-ng2 is no longer being released at the same time as angular-ui-router. This is a major release of angular-ui-router with lots of new features, and includes most of the remaining breaking changes required for a 1.0 final release.

If you're still using the 0.2.x or 0.3.x versions, this is a good time to migrate your codebase to the latest version. See the migration guide to get started. (Note: the migration guide will be updated with the breaking changes from this release ASAP).

The following list highlights the most notable changes in this release:

  • Route-to-component
    • Now supports binding to a child state component from the parent state's component through the ui-view tag (for handling events from dumb components, etc)
    • Now supports "&" callback bindings to functions returned by resolves
  • Url Rules subsystem overhauled
    • Now, the most relevant URL is matched, instead of the rule that was registered first ui-router/core#15
  • Query parameters no longer encode slashes as ~2F
    • New param types: path, query, hash
  • Hash parameter is cleared out on subsequent transitions (it is no longer an inherited param)
  • Use { location: 'replace' } when a URL redirect occurs. This eliminates the extra entry in the browser history.
  • Create a new UrlService ($urlService and $urlServiceProvider). This service is a facade which consolidates the most commonly used URL APIs. The other URL apis still exist, but are marked as deprecated for public use.
  • Typescript definitions (.d.ts) are now compatible with Typescript 1.8.x
  • Implemented NOWAIT resolve policy (do not wait for promises; do not unwrap promises)
  • ui-sref/-active
    • Links update when states are added/removed
    • Params-only srefs work properly (only change params on the current state)
  • ui-view
    • States without any views (template or component) get a template of <ui-view></ui-view> allowing easier creation of abstract states
  • Use $templateRequest by default to fetch templates
  • Lazy Load
    • More flexible lazy loading (lazy load anything: states, components, services -- whatever you need)
    • Imperative lazy loading (can be used to pre-load lazy states)
    • Bugfixes

1.0.0-rc.1 (2017-01-09)

Bug Fixes

  • Post-process .d.ts files to make them compatible with TS 1.8 (c8162ee), closes #3070
  • $stateChangeSuccess: fire polyfill $stateChangeSuccess right after global state are updated (3984f9b), closes #3144
  • $viewContentLoading: Add $viewContentLoading event back (c346a28)
  • build: Use global angular reference if require('angular') is falsey or empty (2982613), closes #3113
  • component: Do not throw err when component has & binding (b5c731d), closes #3099
  • Ng1ViewDeclaration: Make controllerProvider IInjectable (#3056) (a3136ae), closes #3044
  • ng2.uiSrefActive: Allow ng-if on nested uiSrefs (e3051f5), closes #3046
  • onExit: inject resolve values using the "from path" (c91b65a)
  • onExit: inject the current transition as $transition$ (c91b65a), closes #3081
  • package: use engines: node: >=4.0.0 (6801b0c), closes #3086
  • Resolve: Fix NOWAIT resolve injection into controllers and bindings to components. (cb57ce9)
  • typings: Change Ng1ViewDeclaration.controller type to IInjectable|string (d2b5d84), closes #3089
  • typings: Change Ng1ViewDeclaration.controller type to IInjectable|string (8e91dc9)
  • ui-sref: Update ui-sref/state href when states are added/removed (389dfd5)
  • ui-sref: Update params-only sref when state changes (3c1bd0e), closes #1031 #2541
  • ui-sref: Use either .on or .bind for click handlers (b00f044), closes #3035
  • ui-sref-active: Add CSS class immediately (avoid delay) (27eb5e9), closes #2503
  • ui-sref-active: Avoid add/remove class race condition (126a4ad)
  • ui-sref-active: Use $scope.$evalAsync to apply css class (6a9d9ae), closes #2503 #1997 #2503 #1997
  • ui-state: Process ui-state links relative to where they are created (cae4dc4)
  • ui-state: Support one time bindings in ng 1.3 (389dfd5), closes #3131 #3054
  • uiView: do not leave initial view scope undestroyed (#3164) (37d6f9a), closes #1896

Features

  • bundle using rollupjs for smaller bundle and faster init times (a4b5500)
  • Deprecate public use of $urlRouter and $urlMatcherFactory in favor of $urlService (6ee7f21)
  • Move imperative $resolve service out of main bundle (cae6d03)
  • remove component.json (af736c4)
  • Use angular 1.3+ $templateRequest service to fetch templates (7e1f36e), closes #3193 #1882
  • $uiRouter: expose router instance at config-time as $uiRouterProvider.router (9d2661c)
  • injectables: Expose $uiRouterProvider, $uiRouterGlobals, and $stateRegistry injectables (7fa72a6)
  • ui-sref-active: improve performance by reducing $watches (126a4ad)
  • ui-view: Route-to-component: Wire component "&" bindings (af95206), closes #3239 #3111
  • UrlService: Create UrlService API (facade) for easier access to URL based APIs (6ee7f21)
  • view: A view without anything to render defaults to <ui-view></ui-view> (7d28fdd), closes #3178
  • view: Route a view to a directive using componentProvider (#3165) (090d2e3)

BREAKING CHANGES

BREAKING CHANGE: Deprecate public use of $urlRouter and $urlMatcherFactory in favor of $urlService

The UrlService combines the commonly used URL APIs in a single place.
The service may be injected in a run block as $urlService, or in a config block as $urlServiceProvider.

The service object has two nested API objects, rules and config. An example usage is $urlService.rules.otherwise('/home')

The existing API for $urlRouter and $urlMatcherFactory will continue to function as before, but are now considered an "internal API".\
The new $urlService is a facade which delegates to the appropriate internal APIs.

BREAKING CHANGE: Use angular 1.3+ $templateRequest service to fetch templates

We now fetch templates using $templateRequest when it is available (angular 1.3+).
You can revert to previous template fetching behavior using $http by configuring the ui-router $templateFactoryProvider.

.config(function($templateFactoryProvider) {
  $templateFactoryProvider.shouldUnsafelyUseHttp(true);
});

There are security ramifications to using $http to fetch templates.
Read
Impact on loading templates
for more details

BREAKING CHANGE: Move imperative $resolve service out of main bundle

The $resolve service's .resolve() method can be used to perform async dependency injection imperatively.

The code has been moved out of the main angular-ui-router codebase and is now opt-in.
For prebuilt bundle users, add release/resolveService.js to your project.
For self-bundlers (e.g., webpack), add angular-ui-router/release/lib/resolveService as an import or require().

It's unlikely you use this service.
Its most common usage is with the UI-Bootstrap $modal service.

BREAKING CHANGE: remove component.json

ui-router-core changes

This release of angular-ui-router (1.0.0-rc.1) updates ui-router-core to 3.1.0
These are the changes in ui-router-core from 1.0.0-beta.3 to 3.1.0

3.1.0 (2017-01-09)

Bug Fixes

  • lazyLoad: Sync by URL after nested lazy load triggered by URL (1c6220c)
  • lazyLoad: Use UrlService.match() to retry url sync after successful lazy load triggered by url (8c2461d), closes #19
  • Ng1ViewDeclaration: Make controllerProvider IInjectable (#3056) (a3136ae), closes #3044
  • ng2.uiSrefActive: Allow ng-if on nested uiSrefs (e3051f5), closes #3046
  • onBefore: Skip remaining hooks after the (#2) (8a45d04)
  • param: params: { foo: { raw: true } } overrides ParamType.raw (aefeabf)
  • Param: Mark all query parameters as optional (7334d98)
  • params: Check for null in int param type is() check (aa551e4), closes #3197
  • redirect: Do not allow onBefore hooks to cause infinite redirect loops (5c5f7eb), closes #6
  • redirectTo: Do not puke when redirectTo returns undefined (bde9c0f)
  • redirectTo: fix TS type signature of redirectTo (2c059c4)
  • StateQueueManager: Compare parsed url parameters using typed parameters (beca1f5)
  • StateRegistry: Fix error message: State '' is already defined (f5bd96b)
  • StateService: Compare typed parameters in .is() and .includes() (b1a5155)
  • TargetState: Narrow name() return type to String (a02f4a7)
  • Transition: Use { location: replace } when redirecting a transtition in response to a URL sync (23e2b78)
  • typescript: Emit TS 1.8 compatible .d.ts files (65badf4)
  • typings: Allow urlRouter.rule to return void (0b78bdf)
  • ui-sref: Use either .on or .bind for click handlers (b00f044), closes #3035
  • UrlRouter: Use { location: 'replace' } whenever a url redirect happens (6cf9b8f)
  • UrlService: Wire urlMatcherFactory and urlRouter functions (a7b58d6)
  • vanilla: vanilla locations: do not parse "empty string" query key parameter (f949480)
  • view: Load view prerequisites in onFinish (cc85e76)
  • view.load: Allow view.load to return synchronously (8619cf9)

Features

  • (CoreServices) Move location and locationConfig from services to UIRouter.locationService and UIRouter.locationConfig. (029fb00)
  • Built-in string parameter type no longer encodes slashes as ~2F nor tildes as ~~ (72bb2d8)
  • Create router.dispose() to dispose a router instance and resources. (0690917)
  • Hook errors are all normalized to a "Rejection" type. To access the detail of the error thrown (throw "Error 123"), use .detail, i.e.: (f486ced)
  • Move html5Mode and hashPrefix from LocationServices to LocationConfig interface (9d316a7)
  • move ViewService.viewConfigFactory and rootContext to _pluginapi.* (65badf4)
  • Move html5Mode and hashPrefix to LocationServices from LocationConfig (f7ac2bb)
  • Order URL Matching Rules by priority, not registration order (eb2f5d7)
  • Path/Query parameters no longer default to string param type (72bb2d8)
  • Previously, a state with a lazyLoad function was considered a future state. (ec50da4)
  • Remove getResolveValue and getResolvable methods from Transition in favor of injector().get() and injector().getAsync() (111d259)
  • Replace LocationServices.setUrl with LocationServices.url (4c39dcb)
  • Replace UrlRouterProvider/UrlRouter with just UrlRouter (fddd1e2)
  • assertMap: Add a [].map() helper that asserts that each element is truthy (f044f53)
  • futureState: States with a .** name suffix (i.e., foo.**) are considered future states (ec50da4)
  • hash: Change the hash parameter type ('#') to inherit: false so it is cleared out when another transition occurs. (849f84f), closes #3245 #3218 #3017
  • HookBuilder: Allow custom hook types (to be defined by a plugin) (3f146e6)
  • lazyLoad: Created StateService.lazyLoad method to imperatively lazy load a state (ec50da4), closes #8
  • lazyLoad: Exported/exposed the lazyLoadState function (ec50da4)
  • lazyLoad: the lazyLoad hook can be used to lazy load anything (component code, etc) (ec50da4), closes #4
  • LocationServices: Add a parts() method which returns the URL parts as an object (32e64f0)
  • onCreate: Add onCreate transition hook (f486ced)
  • params: Add path and query param types (72bb2d8)
  • params: add option to use generic type for Transition.params (#17) (eb12ec8), closes #16
  • Params: Allow inherit: false specified per parameter or type (849f84f)
  • plugin: Allow all plugins to be gotted. (e324973)
  • plugin: Allow registration by ES6 class, JS constructor fn, JS factory fn (b9f4541)
  • plugin: Create plugin API (36a5215), closes #7
  • Resolve: implement NOWAIT policy: Do not wait for resolves before completing a transition. (05d4c73), closes #3243 #2691
  • State: add .parameters() option for filtering to matching keys (beca1f5)
  • transition: Allow plugins to define own transition events like onEnter (0dc2c19)
  • transition: Create (2673406)
  • Transition: Add Transition.originalTransition() to return the initial transition in a chain of redirects (4fe39e3)
  • Transition: Allow injector() to retrieve resolves for the exiting states/path (df502e8)
  • Transition: Allow a plain object ResolvableLiteral in Transition.addResolvable (ad9ae81)
  • Transition: Make Transition.params() immutable to avoid confusion about mutability (0162212)
  • Transition: Support treechange paths in API for Resolve+transition (beedc82)
  • UrlMatcher: Add comparison function by UrlMatcher specificity (eb2f5d7)
  • UrlRouter: sort url rules by specificity, not by registration order. (eb2f5d7)
  • UrlService: allow eager or lazy binding of location objects during construction (7e0a8af)
  • UrlServices: Add match(): given a URL, return the best matching Url Rule (32e64f0)
  • vanilla: Implement in-memory-only location api (f64aace)

BREAKING CHANGES

BREAKING CHANGE: Remove getResolveValue and getResolvable methods from Transition in favor of injector().get() and injector().getAsync()

In beta.3, the Transition APIs: injector(), getResolvable, and getResolveValue duplicated functionality.

Instead of:

trans.getResolveValue('myResolve');

use:

trans.injector().get('myResolve')

BREAKING CHANGE: Hook errors are all normalized to a "Rejection" type. To access the detail of the error thrown (throw "Error 123"), use .detail, i.e.:

Before

$state.go('foo').catch(err => { if (err === "Error 123") .. });

New way

$state.go('foo').catch(err => { if (err.detail === "Error 123") .. });

BREAKING CHANGE: Replace LocationServices.setUrl with LocationServices.url

This makes url() a getter/setter. It also adds the optional state parameter to pass through to the browser history when using pushstate.
End users should not notice this change, but plugin authors may.

BREAKING CHANGE: Replace UrlRouterProvider/UrlRouter with just UrlRouter

The configuration functions from the provider object have been integrated into the normal UrlRouter object.
The UIRouter object no longer has a uriRouterProvider, but the equivalent functions can be found on uiRouter

One difference between the old functions on urlRouterProvider and the new ones on uriRouter is that new functions do not accept injectable functions.

BREAKING CHANGE: Built-in string parameter type no longer encodes slashes as ~2F nor tildes as ~~

Previously, the string parameter type pre-encoded tilde chars (~) as two tilde chars (~~) and slashes (/) as ~2F. This meant if you provided a parameter value such as { queryParam: '/foo' }, it was always encoded as ?queryParam=~2Ffoo.

Now, the built-in string parameter type does not pre-encode slashes nor tildes.
If you rely on the previous encoding, create a custom parameter type that implements the behavior:

urlMatcherFactory.type('tildes', {
  encode: (val: any) =>
      val != null ? val.toString().replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m])) : val;
  decode: (val: string) =>
      val != null ? val.toString().replace(/(~~|~2F)/g, m => ({ '~~': '~', '~2F': '/' }[m])) : val;
  pattern: /[^/]*/
});

However, any path parameters (/foo/:param) are still encoded using tildes. See below for details.

BREAKING CHANGE: Path/Query parameters no longer default to string param type

Previously, if a url parameter's type was not specified (in either the path or query), it defaulted to the string type.

Now, path parameters default to the new path type and query parameters default to the new query type.

In Angular 1 only, the new path parameter type retains the old behavior of pre-encoding ~ to ~~ and / to ~2F

BREAKING CHANGE: Order URL Matching Rules by priority, not registration order

URL Rules can be defined by multiple sources: registered states' .urls, calling .when(), or calling .rule(). It is possible for two or more URL Rules to match the URL.

Previously

Previously, url rules were matched in the order in which they were registered.
The rule which was registered first would handle the URL change.

Now

Now, the URL rules are sorted according to a sort function.
More specific rules are preferred over less specific rules.

Why

It's possible to have multiple url rules that match a given URL.
Consider the following states:

  • { name: 'books', url: '/books/index' }''
  • { name: 'book', url: '/books/:bookId' }''

Both states match when the url is /books/index.
Additionally, you might have some custom url rewrite rules such as:

.when('/books/list', '/books/index').

The book state also matches when the rewrite rule is matched.

Previously, we simply used the first rule that matched. However, now that lazy loading is officially supported, it can be difficult for developers to ensure the rules are registered in the right order.

Instead, we now prioritize url rules by how specific they are.
More specific rules are matched earlier than less specific rules.
We split the path on /.
A static segment (such as index in the example) is more specific than a parameter (such as:bookId).

More Details

The built-in rule sorting function (see UrlRouter.defaultRuleSortFn) sorts rules in this order:

  • Explicit priority: .when('/foo', '/bar', { priority: 1 }) (default priority is 0)
  • Rule Type:
    • UrlMatchers first (registered states and .when(string, ...))
    • then regular Expressions (.when(regexp, ...))
    • finally, everything else (.rule())
  • UrlMatcher specificity: static path segments are more specific than variables (see UrlMatcher.compare)
  • Registration order (except for UrlMatcher based rules)

For complete control, a custom sort function can be registered with UrlService.rules.sort(sortFn)

Query params

Because query parameters are optional, they are not considered during sorting.
For example, both these rules will match when the url is '/foo/bar':

.when('/foo/bar', doSomething);
.when('/foo/bar?queryparam', doSomethingElse);

To choose the most specific rule, we match both rules, then choose the rule with the "best ratio" of matched optional parameters (see UrlRuleFactory.fromUrlMatcher)

This allows child states to be defined with only query params for a URL.
The child state only activates if the query parameter is present.

.state('parent', { url: '/parent' });
.state('parent.child', { url: '?queryParam' });

Restoring the previous behavior

For backwards compatibility, register a sort function which sorts by the registration order:

myApp.config(function ($urlServiceProvider) {

  function sortByRegistrationOrder(a, b) {
   // each rule has a $id which is its registration order
   return a.$id - b.$id; 
  }

  $urlServiceProvider.rules.sort(sortByRegistrationOrder);

});

BREAKING CHANGE: Previously, a state with a lazyLoad function was considered a future state.

Now, a state whose name ends with .** (i.e., a glob pattern which matches all children) is considered a future state.

All future states should be given a name that ends in .**.

Change your future states from:

{ name: 'future', url: '/future', lazyLoad: () => ... }

to:

{ name: 'future.**', url: '/future', lazyLoad: () => ... }

BREAKING CHANGE: (CoreServices) Move location and locationConfig from services to UIRouter.locationService and UIRouter.locationConfig.

The core services object is a mutable object which each framework was monkey patching.
This change removes the requirement to monkey patch a global mutable object.
Instead, framework implementors should pass the LocationServices and LocationConfig implementations into the UIRouter constructor.

End users should not notice this. However, if you were accessing services.location or services.locationConfig, you should access these off the $uiRouter instance instead.

BREAKING CHANGE: Move html5Mode and hashPrefix from LocationServices to LocationConfig interface

End users should not notice this.

BREAKING CHANGE: move ViewService.viewConfigFactory and rootContext to _pluginapi.*

This BC happened in commit 6c42285

End users should not notice this.

BREAKING CHANGE: Move html5Mode and hashPrefix to LocationServices from LocationConfig

End users should not notice this.

Downloads

0.3.2

@christopherthielen christopherthielen released this Nov 3, 2016 · 893 commits to master since this release

(2016-11-03) diff

Bug Fixes

  • $state.transitionTo: trigger $stateChangeCancel appropriately (#3039) (ca7c366), closes #3027
  • promise: avoid uncaught in promise errors due to transition rejections (66ab048), closes #2889
  • state.includes: compare param vals using typed parameter (not using ==) (6958c24), closes #2696
  • stateDirective: using on to attach an event handler instead of bind (#3036) (a8aa40a)
  • urlMatcherFactory: fix tilde edge case with "string" encoding (#3021) (953235a)

Downloads

1.0.0-beta.3

@christopherthielen christopherthielen released this Sep 23, 2016 · 119 commits to master since this release

(2016-09-23) diff

Read more on the blog

This release adds Angular 2.0.0 final support.
It changes the NgModule mechanism to use UIRouterModule.forRoot() and UIRouterModule.forChild().
See the blog and the breaking changes section.

Bug Fixes

This release fixes bugs for both ng1 and ng2

  • common: Remove url() from LocationService interface (#2990) (d6c2580)
  • lazyLoad: Always delete the lazy load promise after it settles. (dd2f101)
  • ng1.StateProvider: Export StateProvider class so type can be used (167770d)
  • ng1.uiView: Remove deprecated jquery functions bind/unbind in favor of on/off (60ebd44)
  • ng2: Angular 2.0.0 final compatibility (7c54b75), closes #2991
  • ng2.NgModule: Allow apps with no forChild modules (d3bd332), closes #3009
  • ng2.uiView: Use ReflectorReader to get component inputs
  • resolve: Don't re-resolve data when redirected to same state, but only dynamic params changed. (98cd2d2), closes #3033
  • trace: Show function definition during logging of trace.enable('HOOK') (190d122)
  • transition: Fail a transition if a new one has started while resolves are loading (bc87d9e), closes #2972
  • urlMatcherFactory: fix tilde edge case with "string" encoding (#3018) (a201906)
  • viewService: Allow root ui-view to be wrapped in ng-if (32f718a), closes #3004

Features

  • StateBuilder: Calculate parent state name when ends in two wildcards ** (b4621f3)

BREAKING CHANGES

BC in Core

  • Remove UIInjector.native infavor of UIInjector.getNative() (d11b7dc)
  • Remove stateProvider from ui-router-core. Use stateRegistry and stateService in 88c6494
  • We now enforce states with an explicit parent: may NOT ALSO specify a parent state in their name (i.e., parent.child)

BC in Angular 2

Major breaking changes for Angular 2 bootstrap between beta.2 and beta.3

@NgModule({
  imports: [
    UIRouterModule.forRoot({
      states: INITIAL_STATES,
      useHash: true,
      configClass: MyUIRouterConfig
    }),
    BrowserModule,
    FeatureModule,
  ],
  declarations: INITIAL_COMPONENTS
})
class RootAppModule {}

@NgModule({
  imports: [
    UIRouterModule.forChild({
      states: FEATURE_STATES,
      configClass: FeatureConfig
    }),
    CommonModule,
  ],
  declarations: FEATURE_COMPONENTS
})

Downloads

1.0.0-beta.2

@christopherthielen christopherthielen released this Sep 10, 2016 · 149 commits to master since this release

(2016-09-09) diff

Read more about beta.2 on the blog

BC-BREAK

1) State Glob patterns have been changed slightly.

Previously, a single wildcard foo.* could match "missing segments" on the end of a state name.
For example, foo.* would match the state foo.
Likewise, foo.*.*.* would also match the foo state.

Now, a single wildcard matches exactly one segment.
foo.* will match foo.bar and foo.baz, but neither foo nor foo.bar.baz.

If you previously relied on the single wildcard to match missing segments, use a double wildcard, foo.**.

Double wildcards match 0 or more segments.

Read more about Glob matching

2) (obscure) Angular 1 DI token ng1UIRouter renamed to $uiRouter

3) (obscure) Renamed Transition.previous() to Transition.redirectedFrom()

Features

Core

  • lazyLoad: Add state.lazyLoad hook to lazy load a tree of states (bef5257) (8ecb6c6), closes #146 #2739
  • StateRegistry: Add deregister method. (44579ec), closes #1095 #2711
  • redirectTo: Process redirectTo property of a state as a redirect string/object/hook function (6becb12), closes #27 #948
  • redirect: Error after 20+ redirected transitions (88052bf)
  • rejectFactory: separate transition aborted and transition errored reject types (55995fd)
  • Resolve: support ng2-like provide object literals (a7e5ea6)
  • Resolve: Switch state.resolve to be an array of Resolvables (6743a60)
  • Transition: Add the transition source (url/sref) to TransitionOptions (5d42d79)
  • Transition: Added getResolvable(token) method (3aee2b7)
  • Transition: expose the current UiRouter object as a public property (52f1308)
  • Transition: expose the transition rejection reason as Transition.error() (7a9e383), closes #2866
  • Transition: Expose the transition's TargetState as targetState() (f06f6b6)
  • urlRouter: Allow a rule to be deleted. (55f3d3d)

ng2

  • ng2.rx: Added RxJS Observables for transitions and states: (2a2f381)
  • ng2: Add @UIRouterModule decorator (e7bedc2), closes #2922
  • ng2: Improve ng2 bootstrap flexibility with provideUIRouter() provider factory function (bc17066), closes #2958
  • ng2.UrlRouter: Implement { location: replace } (b8c6146), closes #2850
  • ng2.NgModule: Add module's states to DI using UIROUTER_STATES_TOKEN (0cb628e)
  • ng2.stateRegistry: Automatically register states defined on a UIRouterModule (58a3c84)
  • ng2.UIView: Use merged NgModule/ParentComp to inject routed component (37241e7)
  • ng2.upgrade: Enable ng1-to-ng2 (0bf4eb4)
  • uiView: Support Components loaded via AppModule (696148f)

Bug Fixes

Core

  • defaultErrorHandler: Invoke handler when a transition is Canceled. (4fcccd8), closes #2924
  • defaultErrorHandler: log Error and Error.stack by default (e102a85)
  • defaultErrorHandler: Reduce console.error noise when redirected (8c0344f)
  • common: Add concrete import to interface.ts to fix unit tests (2d16740)
  • redirect: fix bug where redirected transitions with reload: true got wrong resolve values copied (bd0e3a3)
  • redirectTo: fix redirectTo definition (interface) (eff7195), closes #2871
  • Rejection: Silence "Error: Uncaught (in Exception)" (38432f4), closes #2676
  • Resolve: prevent RXWAIT from waiting for the observable to complete (a02caf3)
  • ResolvePolicy: Fix resolve policy config loading (4440811), closes #2945
  • stateService: change reloadState parameter in reload function is optional (#2973) (839dc4a)
  • StateService: remove jQuery deprecated feature (fa40acc)
  • trace: make TRANSITION trace less noisy when a transition is redirected (a65c58f)
  • Trace: Fix error in console after $trace.enable() (013c77a), closes #2752
  • transitionHook: Prevent queued hookFn to be called if deregistered (#2939) (39e1ba7), closes #2928
  • typescript: Make UI-Router noImplicitAny safe. (0769bc2), closes #2693
  • typescript: Remove angular1 specific types from ui-router-core methods (30124bd), closes #2693

ng1

  • ng1.stateService: Coerce 'null' params value to empty object (f674151), closes #2952
  • ng1.uiSref: Allow nested UISrefs by stopping event propagation on-click (b4a2499), closes #2962
  • ng1.uiSrefActive: update sref-active after existing transition-in-progress completes (0994c71), closes #2908
  • uiSref, uiState: added click unbind to prevent memory leaks (79d501e)
  • uiView: separate $uiView and $uiViewAnim element.data() (a94117d), closes #2763

ng2

  • ng2.pushState: Properly match urls when base path set (b9be2dc), closes #2745
  • ng2.UIRouterConfig: Allow new UIRouter() to finish before configuring it (a151f71)
  • ng2.uiSrefActive: Allow uiSrefActive on ancestor element. (874fc07), closes #2950
  • ng2.uiSrefActive: don't puke on sref to invalid target state (c9b6570)
  • ng2.UISrefActive: Use @ContentChildren to query for the nested UISref (999c42a), closes #2950
  • ng2.UiView: fix input resolve binding (4f53f81)
  • ng2.UIView: Make routed to component appear inside UIView, not next to it. (558fc80)

Downloads

UI-Router 1.0 beta release

@christopherthielen christopherthielen released this Jun 30, 2016 · 226 commits to master since this release

(2016-06-30) diff

beta documentation

UI-Router has a new home

https://ui-router.github.io/

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

1) 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

2) 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 current Transition, which has an injector() function
  • state: for onEnter/onRetain/onExit hooks only, the State which the hook is being run for. This value will be null for onBefore/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

3) BC-BREAK: Removed Transition.resolves() in favor of Transition.getResolveValue(token) and Transition.getResolveTokens()

This change is necessary to support injection tokens of arbitrary types, not just strings.

4) 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.

5) BC-BREAK: - Removed the default resolve called $resolve$, which was added in a previous alpha.

6) BC-BREAK: - Transition.addResolves()  replaced with Transition.addResolvable()

7) BC-BREAK: remove ResolveContext.getResolvables() in favor of .getToken()and.getResolvable()`

8) BC-BREAK: remove ResolveContext.invokeLater() and .invokeNow()

9) BC-BREAK: remove support for JIT resolves. This also eliminated the need for the loadAllControllerLocals 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
  });
});
```

10) BC-BREAK: Replaced ViewConfig.node with ViewConfig.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.

11) BC-BREAK: Nodes no longer have (stateful) .resolveContext properties. Instead, a new ResolveContext is wrapped over a Path of Nodes when needed.  Removed PathFactory.bindResolveContexts().

12) 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().

13) BC-BREAK: Removed ResolvePolicy enum in favor of the ResolvePolicy interface { when: "", async: "" }

14) BC-BREAK: renamed ResolveContext.isolateRootTo to subContext

15) BC-BREAK: rename UIRouterGlobals class to Globals; add UIRouterGlobals back as an interface

16) BC-BREAK: Moved defaultErrorHandler from TransitionService to StateService

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

Downloads

0.3.1

@christopherthielen christopherthielen released this Jun 3, 2016 · 893 commits to master since this release

(2016-06-03) diff

obscure BC-BREAK

If you're using element.data('$uiView').$animEnter, switch to element.data('$uiViewAnim').$animEnter
This was necessary in order to fix #2763

Bug Fixes

  • state:
    • fire $stateChangeError if onEnter/onExit throws. closes #2772 (a5756c38)
    • fail transition on exceptions in transition handler (8222fb0e)
  • uiView: separate $uiView and $uiViewAnim element.data() (d3502f3c, closes #2763)
    • Fixes this error: Cannot read property 'name' of undefined at getUiViewName

Downloads

legacy maintenance release

@christopherthielen christopherthielen released this May 14, 2016 · 893 commits to master since this release

(2016-05-14) diff

This is a release of the legacy branch, primarily to fix the $scope destroy ordering issues introduced in 0.2.16, as well as adding $scope.$resolve to enable "route-to-component-template".

We recommend all users to try the 1.0.0 alpha and report any issues it causes with your application. Read the known breaking changes between the legacy and 1.0 branches.

BC-BREAK

In 0.2.16 we delayed the ui-view $scope destroy() until after all animations were completed. This was a mistake, and we're reverting it in 0.3.0.

The original issue that we tried to address: #1643

We are switching back to 0.2.15 behavior. The scope is now destroyed as soon as the view is swapped out. This allows cleanup to happen in response
to the $destroy event. If you need to do things after the animation, we've put the promise on the element.data('$uiView') in #2562

Bug Fixes

  • state: Inject $state at runtime to force initialization (de3a04a7, closes #2574)
  • ui-sref: update ui-sref-active/eq info when params change When ui-state dynamicly changes (9698ec4d, closes #2554)
  • ui-state: update ui-sref-active/eq info when ui-state dynamicly changes watchers, make sur (abb3deba, closes #2488)

Features

  • resolve: Put resolve values on the scope as $scope.$resolve

    This enables easier "routing-to-component-template", i.e.,

    .state({ name: 'foo', 
      resolve: { thing: (MyService) => MyService.getThing() }
      template: '<my-component component-input="$resolve.thing"></my-component>'
    });
    
  • uiView:

Downloads

1.0.0-alpha.5

@christopherthielen christopherthielen released this May 13, 2016 · 274 commits to master since this release

(2016-05-12) diff

Features

ng2

  • ng2.uiView: bind resolve data to input[] and @Input(), process bindings:(f6dae28)
  • ng2.urlRouter: HTML5 PushState support(9842fb7), closes #2688
  • ng2.UIRouter: update to ng2 beta.17(45c0758)
  • ng2.UIRouter: Update ui-router for ng2 rc.1(3219406), closes #2722

Bug Fixes

ng1

  • ng1.component: Allow route-to-component "@" and optional bindings(71b3393), closes #2708
  • view: only run ng1 route-to-component code if component: is a string(ec1c534)

ng2

  • ng2.uiSrefStatus: Avoid "dehydrated detector" error(9111727), closes #2684
  • ng2.uiView: Fix "Invalid left-hand in assignment"(3f711a1)
  • build: declare external dep on angular/core in webpack bundle(adfbde3), closes #2687

Core

  • attachRoute: Do not update URL after syncing from url(8742511), closes #2730
  • common: only use window if available(32ff988)
  • coreservices: Use Promise.reject()/resolve()/all()(62b2ebc), closes #2683
  • paramTypes.hash: Update hash for each transition(79d4fd7), closes #2742
  • Rejection: Dont log an ignored trans as console.error(7522c26), closes #2676
  • resolve: Fix regression; Allow resolve values to be service names(a34fd3b), closes #2588
  • StateQueueManager: Do not throw on orphan states.(95ae0cf), closes #2546
  • TransitionManager: Update url even when the Transition is ignored.(f9c3e3c), closes #2723

Downloads

1.0.0-alpha.4

@christopherthielen christopherthielen released this Apr 6, 2016 · 300 commits to master since this release

(2016-04-06) diff

Downloads

1.0.0-alpha.3

@christopherthielen christopherthielen released this Apr 3, 2016 · 305 commits to master since this release

(2016-04-03) diff

Note: 1.0.0-alpha.2 and 1.0.0-alpha.3 are identical.

Angular 2

This is the first UI-Router release with angular 2 support.

See quickstart-ng2 for a small ui-router-ng2 app

The first pass at ng2 docs may be found here

NG2 support is a work in progress.

In particular, only hashbang routing is supported at the moment.

Also, injecting resolves and transition hooks is currently only possible using the angular1 style string-based injection. Any global providers that you want injected into a resolve or hook should be mapped to a string. See this example for how to do that.

Bug Fixes

  • ViewHooks: Avoid calling $onInit if angular 1.5 will call it for us (d42b617), closes #2660
  • ViewHooks: Fix problem with injecting uiCanExit (76ab22d), closes #2661
  • view: temporary sanity check that a node exists (1c0edeb), closes #2657
  • justjs.$q: Fix $q.all([..]) and $q.all({...}) (b1624c6)
  • ng2.uiSref: Fix anchor href generation (98b5b42)
  • ng2.uiSrefStatus: calculate target state parameters (46cdf4c)
  • ng2.uiView: Dispose prev comp on empty viewconfig (f28e0c3)

Features

  • UIRouterConfig: Define UIRouterConfig class for router bootstrap (c16b9e6)
  • UIRouterGlobals: Create UIRouterGlobals (0eb7406), closes #2525
  • ui-router-ng2: Update providers and viewsBuilder to match new 1.0 API (ff54d61)
  • ng2.uiSrefActive: Implement uiSrefStatus, uiSrefActive, uiSrefActiveEq (fcb15c5)

Downloads