本文整理汇总了TypeScript中angular2-universal.platformUniversalDynamic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript platformUniversalDynamic函数的具体用法?TypeScript platformUniversalDynamic怎么用?TypeScript platformUniversalDynamic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了platformUniversalDynamic函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: platformUniversalDynamic
compiler.plugin('emit', (_compilation, _callback) => {
this.platformRef = this.platformRef || platformUniversalDynamic();
this._options.document = this._options.document || _compilation.assets[this._options.documentPath].source();
const zone = Zone.current.fork({
name: 'UNIVERSAL prerender',
properties: this._options
});
zone.run(() => (this.platformRef.serializeModule(this._options.ngModule, this._options))
.then((html) => {
if (typeof html !== 'string' || this._options.cancel) {
_compilation.assets[this._options.documentPath] = {
source: () => this._options.document,
size: () => this._options.document.length
};
return _callback();
}
_compilation.assets[this._options.documentPath] = {
source: () => html,
size: () => html.length
};
return _callback();
})); // zone.run
}); // compiler.plugin
示例2: platformUniversalDynamic
platform: (providers) => platformUniversalDynamic(providers),
示例3: enableProdMode
/**
* the polyfills must be the first thing imported
*/
import './polyfills.ts';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { platformUniversalDynamic } from 'angular2-universal';
import { AppModule } from './app/app.browser.module';
/**
* enable prod mode for production environments
*/
if (environment.production) {
enableProdMode();
}
const platformRef = platformUniversalDynamic();
/**
* bootstrap Angular 2 on document ready
*/
document.addEventListener('DOMContentLoaded', () => {
platformRef.bootstrapModule(AppModule);
});
示例4: enableProdMode
import './polyfills.browser.aot';
import './rxjs.imports';
import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
import { AppModuleNgFactory } from '../compiled/src/app/app.module.universal.browser.ngfactory';
if ('production' === ENV) {
enableProdMode();
}
export const platform = platformUniversalDynamic();
export function main() {
return platform.bootstrapModuleFactory(AppModuleNgFactory)
.catch(err => console.log(err));
}
export function bootstrapDomReady() {
document.addEventListener('DOMContentLoaded', main);
}
bootstrapDomReady();
示例5: main
export function main(): Promise<any> {
return platformUniversalDynamic()
.bootstrapModule(AppModule)
.then(decorateModuleRef)
.catch(err => console.error(err));
}
示例6: main
export function main() {
return platformUniversalDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
}