Skip to content

Commit

Permalink
BREAKING CHANGE: Deprecate public use of $urlRouter and `$urlMatche…
Browse files Browse the repository at this point in the history
…rFactory` 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.

feat(UrlService): Create UrlService API (facade) for easier access to URL based APIs
  • Loading branch information
christopherthielen committed Jan 5, 2017
1 parent 7e1f36e commit 6ee7f21
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
IRootScopeService, IQService, ILocationService, ILocationProvider, IHttpService, ITemplateCacheService
} from "angular";
import {
services, applyPairs, isString, trace, extend, UIRouter, StateService, UrlRouter, UrlMatcherFactory, ResolveContext
services, applyPairs, isString, trace, extend, UIRouter, StateService, UrlRouter, UrlMatcherFactory, ResolveContext, unnestR
} from "ui-router-core";
import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "./statebuilders/views";
import { TemplateFactory } from "./templateFactory";
Expand Down Expand Up @@ -88,6 +88,14 @@ runBlock.$inject = ['$injector', '$q', '$uiRouter'];
function runBlock($injector: IInjectorService, $q: IQService, $uiRouter: UIRouter) {
services.$injector = $injector;
services.$q = <any> $q;

// The $injector is now available.
// Find any resolvables that had dependency annotation deferred
$uiRouter.stateRegistry.get()
.map(x => x.$$state().resolvables)
.reduce(unnestR, [])
.filter(x => x.deps === "deferred")
.forEach(resolvable => resolvable.deps = $injector.annotate(resolvable.resolveFn));
}

// $urlRouter service and $urlRouterProvider
Expand All @@ -106,6 +114,7 @@ export function watchDigests($rootScope: IRootScopeService) {

mod_init .provider("$uiRouter", <any> $uiRouter);
mod_rtr .provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]);
mod_util .provider('$urlService', getProviderFor('urlService'));
mod_util .provider('$urlMatcherFactory', ['$uiRouterProvider', () => router.urlMatcherFactory]);
mod_util .provider('$templateFactory', () => new TemplateFactory());
mod_state.provider('$stateRegistry', getProviderFor('stateRegistry'));
Expand Down

0 comments on commit 6ee7f21

Please sign in to comment.