當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular2-universal.bootloader函數代碼示例

本文整理匯總了TypeScript中angular2-universal.bootloader函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bootloader函數的具體用法?TypeScript bootloader怎麽用?TypeScript bootloader使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了bootloader函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

export default function (params: aspnet.BootFuncParams): Promise<{ html: string, globals?: any }> {
  const serverBindings = [
    ngCore.provide(BASE_URL, { useValue: '/' }),
    ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
    ngCore.provide(REQUEST_URL, { useValue: params.url }),
    ...ngUniversal.NODE_PLATFORM_PIPES,
    ...ngUniversal.NODE_ROUTER_PROVIDERS,
    ...ngUniversal.NODE_HTTP_PROVIDERS,
    ...provideRouter(routes)
  ];

  let boot = ngUniversal.bootloader({
    directives: [App],
    componentProviders: serverBindings,
    async: true,
    preboot: false,
    // TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
    // Waiting on https://github.com/angular/universal/issues/347
    template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
  })

  return boot.serializeApplication().then(html => {
    boot.dispose();
    return { html };
  });
}
開發者ID:laskoviymishka,項目名稱:Unicorn.Cms,代碼行數:26,代碼來源:boot-server.ts

示例2: function

export default function (params: any): Promise<{ html: string, globals?: any }> {
    const serverBindings = [
        ngCore.provide(ngUniversal.BASE_URL, { useValue: params.absoluteUrl }),
        ngCore.provide(ngUniversal.REQUEST_URL, { useValue: params.url }),
        ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
        ngUniversal.NODE_HTTP_PROVIDERS,
        ngUniversal.NODE_ROUTER_PROVIDERS
    ];
    
    return ngUniversal.bootloader({
        directives: [App],
        providers: serverBindings,
        async: true,
        preboot: false,
        // TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
        // Waiting on https://github.com/angular/universal/issues/347
        template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
    }).serializeApplication().then(html => {
        return { html };
    });
}
開發者ID:Shawn-Fan,項目名稱:NodeServices,代碼行數:21,代碼來源:boot-server.ts

示例3: function

import 'angular2-universal/polyfills';
import * as ngCore from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
import { provideRouter } from '@angular/router';
import * as ngUniversal from 'angular2-universal';
import { BASE_URL, ORIGIN_URL, REQUEST_URL } from 'angular2-universal/common';
import { App } from './components/app/app';
import { routes } from './routes';

const bootloader = ngUniversal.bootloader({
    async: true,
    preboot: false,
    platformProviders: [
        ngCore.provide(APP_BASE_HREF, { useValue: '/' }),
    ]
});

export default function (params: any): Promise<{ html: string, globals?: any }> {
    const config: ngUniversal.AppConfig = {
        directives: [App],
        providers: [
            ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
            ngCore.provide(REQUEST_URL, { useValue: params.url }),
            ...ngUniversal.NODE_HTTP_PROVIDERS,
            provideRouter(routes),
            ...ngUniversal.NODE_LOCATION_PROVIDERS,
        ],
        // TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
        // Waiting on https://github.com/angular/universal/issues/347
        template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
    };
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:31,代碼來源:boot-server.ts


注:本文中的angular2-universal.bootloader函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。