How to use the angular2-universal.platformNodeDynamic 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 DBCG / Dataphor / Dataphoria / Dataphoria.Web.Client.Test / ClientApp / boot-server.ts View on Github external
import 'angular2-universal-polyfills';
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformNodeDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';

enableProdMode();
const platform = platformNodeDynamic();

export default function (params: any) : Promise<{ html: string, globals?: any }> {
    return new Promise((resolve, reject) => {
        const requestZone = Zone.current.fork({
            name: 'angular-universal request',
            properties: {
                baseUrl: '/',
                requestUrl: params.url,
                originUrl: params.origin,
                preboot: false,
                // TODO: Render just the  component instead of wrapping it inside an extra HTML document
                // Waiting on https://github.com/angular/universal/issues/347
                document: ''
            },
            onHandleError: (parentZone, currentZone, targetZone, error) => {
                // If any error occurs while rendering the module, reject the whole operation
github fisenkodv / itinerary / src / Itinerary.Web / Client / boot-server.ts View on Github external
import 'angular2-universal-polyfills';
import 'angular2-universal-patch';
import 'zone.js';
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
import { enableProdMode } from '@angular/core';
import { platformNodeDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';

enableProdMode();
const platform = platformNodeDynamic();

export default createServerRenderer(params => {
  return new Promise((resolve, reject) => {
    const requestZone = Zone.current.fork({
      name: 'angular-universal request',
      properties: {
        baseUrl: '/',
        requestUrl: params.url,
        originUrl: params.origin,
        preboot: false,
        document: ''
      },
      onHandleError: (parentZone, currentZone, targetZone, error) => {
        // If any error occurs while rendering the module, reject the whole operation
        reject(error);
        return true;
github DBCG / Dataphor / Dataphoria / Dataphoria.Web.Client / ClientApp / boot-server.ts View on Github external
import 'angular2-universal-polyfills';
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformNodeDynamic, NodePlatform } from 'angular2-universal';
import { AppModule } from './app/app.module';

enableProdMode();
const platform: NodePlatform = platformNodeDynamic();

export default function (params: any): Promise<{ html: string, globals?: any }> {
    return new Promise((resolve: any, reject: any) => {
        const requestZone: Zone = Zone.current.fork({
            name: 'angular-universal request',
            properties: {
                baseUrl: '/',
                requestUrl: params.url,
                originUrl: params.origin,
                preboot: false,
                // TODO: Render just the  component instead of wrapping it inside an extra HTML document
                // Waiting on https://github.com/angular/universal/issues/347
                document: ''
            },
            onHandleError: (parentZone: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): any => {
                // If any error occurs while rendering the module, reject the whole operation
github TrilonIO / aspnetcore-angular-universal / ClientApp / boot-server.ts View on Github external
import 'angular2-universal-polyfills';
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformNodeDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';

enableProdMode();
const platform = platformNodeDynamic();

export default function (params: any) : Promise<{ html: string, globals?: any }> {
    const requestZone = Zone.current.fork({
        name: 'angular-universal request',
        properties: { 
            baseUrl: '/',
            requestUrl: params.url,
            originUrl: params.origin,
            preboot: false,
            // TODO: Render just the  component instead of wrapping it inside an extra HTML document
            // Waiting on https://github.com/angular/universal/issues/347
            document: ''
        }
    });

    return requestZone.run>(() => platform.serializeModule(AppModule))
github TrilonIO / aspnetcore-angular-universal / src / Angular2Spa / Client / bootstrap-server.ts View on Github external
import 'angular2-universal-polyfills/node';
import './__2.1.1.workaround.ts';
import 'zone.js';

import { enableProdMode } from '@angular/core';
import { platformNodeDynamic } from 'angular2-universal';

import { createServerRenderer, RenderResult } from 'aspnet-prerendering';

// Grab the (Node) server-specific NgModule
import { AppServerModule } from './app/platform-modules/app.server.module';
import { metaStore } from 'app-shared';

enableProdMode();

const platform = platformNodeDynamic();

export default createServerRenderer(params => {

    // Our Root application document
    const doc = '';

    return new Promise((resolve, reject) => {
        const requestZone = Zone.current.fork({
            name: 'Angular-Universal Request',
            properties: {
                ngModule: AppServerModule,
                baseUrl: '/',
                requestUrl: params.url,
                originUrl: params.origin,
                preboot: false,
                document: doc