fix(platform-browser): workaround wrong import path generated by ngc for DOCUMENT (#24830)

This commit is contained in:
vikerman 2018-07-10 17:09:29 -07:00 committed by GitHub
parent 03616bcb43
commit 7d27ecc319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -6,12 +6,13 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Inject, Injectable} from '@angular/core'; import {Inject, Injectable, inject} from '@angular/core';
import {DomAdapter, getDOM} from '../dom/dom_adapter'; import {DomAdapter, getDOM} from '../dom/dom_adapter';
import {DOCUMENT} from '../dom/dom_tokens'; import {DOCUMENT} from '../dom/dom_tokens';
/** /**
* Represents a meta element. * Represents a meta element.
* *
@ -29,12 +30,19 @@ export type MetaDefinition = {
[prop: string]: string; [prop: string]: string;
}; };
/**
* Factory to create Meta service.
*/
export function createMeta() {
return new Meta(inject(DOCUMENT));
}
/** /**
* A service that can be used to get and add meta tags. * A service that can be used to get and add meta tags.
* *
* @experimental * @experimental
*/ */
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root', useFactory: createMeta, deps: []})
export class Meta { export class Meta {
private _dom: DomAdapter; private _dom: DomAdapter;
constructor(@Inject(DOCUMENT) private _doc: any) { this._dom = getDOM(); } constructor(@Inject(DOCUMENT) private _doc: any) { this._dom = getDOM(); }

View File

@ -6,11 +6,17 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Inject, Injectable} from '@angular/core'; import {Inject, Injectable, inject} from '@angular/core';
import {getDOM} from '../dom/dom_adapter'; import {getDOM} from '../dom/dom_adapter';
import {DOCUMENT} from '../dom/dom_tokens'; import {DOCUMENT} from '../dom/dom_tokens';
/**
* Factory to create Title service.
*/
export function createTitle() {
return new Title(inject(DOCUMENT));
}
/** /**
* A service that can be used to get and set the title of a current HTML document. * A service that can be used to get and set the title of a current HTML document.
@ -22,7 +28,7 @@ import {DOCUMENT} from '../dom/dom_tokens';
* *
* @experimental * @experimental
*/ */
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root', useFactory: createTitle, deps: []})
export class Title { export class Title {
constructor(@Inject(DOCUMENT) private _doc: any) {} constructor(@Inject(DOCUMENT) private _doc: any) {}
/** /**