fix(di): update dependency injection and default configs

This commit is contained in:
Adam Bradley
2016-09-16 00:49:09 -05:00
parent 1d403b26ed
commit 7c05d0c0ba
34 changed files with 1396 additions and 1534 deletions

View File

@ -1,4 +1,3 @@
import { Injectable, OpaqueToken } from '@angular/core';
import { Location } from '@angular/common';
import { App } from '../components/app/app';
@ -30,7 +29,6 @@ import { ViewController } from './view-controller';
*/
@Injectable()
export class DeepLinker {
segments: NavSegment[] = [];
history: string[] = [];
@ -415,9 +413,6 @@ export function setupDeepLinker(app: App, serializer: UrlSerializer, location: L
}
export const UserDeepLinkConfig = new OpaqueToken('USERLINKS');
export function normalizeUrl(browserUrl: string): string {
browserUrl = browserUrl.trim();
if (browserUrl.charAt(0) !== '/') {

View File

@ -1,15 +1,13 @@
import { Inject, Injectable } from '@angular/core';
import { OpaqueToken } from '@angular/core';
import { DeepLinkConfig, NavLink, NavSegment } from './nav-util';
import { isArray, isBlank, isPresent, pascalCaseToDashCase } from '../util/util';
import { UserDeepLinkConfig } from './deep-linker';
@Injectable()
export class UrlSerializer {
links: NavLink[];
constructor(@Inject(UserDeepLinkConfig) config: DeepLinkConfig) {
constructor(config: DeepLinkConfig) {
if (config && isArray(config.links)) {
this.links = normalizeLinks(config.links);
@ -265,3 +263,9 @@ function sortConfigLinks(a: NavLink, b: NavLink) {
}
const URL_REPLACE_REG = /\s+|\?|\!|\$|\,|\.|\+|\"|\'|\*|\^|\||\/|\\|\[|\]|#|%|`|>|<|;|:|@|&|=/g;
export const DeepLinkConfigToken = new OpaqueToken('USERLINKS');
export function setupUrlSerializer(userDeepLinkConfig: any): UrlSerializer {
return new UrlSerializer(userDeepLinkConfig);
}