How to use the angular2-universal.platformUniversalDynamic function in angular2-universal

To help you get started, we’ve selected a few angular2-universal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TrilonIO / aspnetcore-angular-universal / Client / bootstrap-client.ts View on Github external
import { AppModule } from './app/app.browser.module';

// Enable either Hot Module Reloading or production mode
// Add Redux HMR state management here

/* tslint:disable */
if (module['hot']) {
    module['hot'].accept();
    module['hot'].dispose(() => { platform.destroy(); });
} else {
    enableProdMode();
}
/* tslint:enable */

// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => { platform.bootstrapModule(AppModule); };

if (document.readyState === 'complete') {
    bootApplication();
} else {
    document.addEventListener('DOMContentLoaded', bootApplication);
}
github fisenkodv / itinerary / src / Itinerary.Web / Client / main.ts View on Github external
// Enable either Hot Module Reloading or production mode
if (module['hot']) {
  module['hot'].accept();
  module['hot'].dispose(() => {
    // Before restarting the app, we create a new root element and dispose the old one
    const oldRootElem = document.querySelector(rootElemTagName);
    const newRootElem = document.createElement(rootElemTagName);
    oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
    platform.destroy();
  });
} else {
  enableProdMode();
}

// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => { platform.bootstrapModule(AppModule); };
if (document.readyState === 'complete') {
  bootApplication();
} else {
  document.addEventListener('DOMContentLoaded', bootApplication);
}
github telerik / kendo-angular-universal-demo / src / client.ts View on Github external
// the polyfills must be the first thing imported
import 'angular2-universal-polyfills';

// Angular 2
import { enableProdMode} from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';

// enable prod for faster renders
enableProdMode();

import { MainModule } from './app/app.browser.module';

const platformRef = platformUniversalDynamic();

// on document ready bootstrap Angular 2
document.addEventListener('DOMContentLoaded', () => {
  platformRef.bootstrapModule(MainModule)//,
});
github qdouble / angular-webpack-starter / src / main.browser.universal.ts View on Github external
export function main() {
  return platformUniversalDynamic().bootstrapModule(AppModule)
    .catch(err => console.log(err));
}
github qdouble / angular-webpack-starter / src / main.browser.universal.aot.ts View on Github external
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();
github angular / universal / modules / webpack-prerender / src / prerender.ts View on Github external
compiler.plugin('emit', (_compilation: any, _callback: any) => {
      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: any) => {
          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,
github netinstructions / 100-days-of-angular2 / client / main.ts View on Github external
import 'angular2-universal-polyfills';
import { platformUniversalDynamic } from 'angular2-universal';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

const platform = platformUniversalDynamic();

if (process.env.ENV === 'production') {
  enableProdMode();
}

platform.bootstrapModule(AppModule);