- PlatformState provides an interface to serialize the current Platform State as a string or Document. - renderModule and renderModuleFactory are convenience methods to wait for Angular Application to stabilize and then render the state to a string. - refactor code to remove defaultDoc from DomAdapter and inject DOCUMENT where it's needed.
34 lines
811 B
TypeScript
34 lines
811 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
const parse5 = require('parse5');
|
|
|
|
import {Injectable, Inject} from '@angular/core';
|
|
import {DOCUMENT} from '@angular/platform-browser';
|
|
|
|
import {getDOM} from './private_import_platform-browser';
|
|
|
|
/**
|
|
* Representation of the current platform state.
|
|
*
|
|
* @experimental
|
|
*/
|
|
@Injectable()
|
|
export class PlatformState {
|
|
constructor(@Inject(DOCUMENT) private _doc: any) {}
|
|
|
|
/**
|
|
* Renders the current state of the platform to string.
|
|
*/
|
|
renderToString(): string { return getDOM().getInnerHTML(this._doc); }
|
|
|
|
/**
|
|
* Returns the current DOM state.
|
|
*/
|
|
getDocument(): any { return this._doc; }
|
|
} |