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


TypeScript Bootloader.serializeApplication方法代碼示例

本文整理匯總了TypeScript中angular2-universal.Bootloader.serializeApplication方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Bootloader.serializeApplication方法的具體用法?TypeScript Bootloader.serializeApplication怎麽用?TypeScript Bootloader.serializeApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2-universal.Bootloader的用法示例。


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

示例1: ngApp

export function ngApp(req, res) {
  const url = req.originalUrl || '/';

  const APP_CONFIG = {
    template: `
    <!doctype html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Angular 2 Universal Starter</title>
        <meta name="description" content="Angular 2 Universal">
        <meta name="keywords" content="Angular 2, Universal, Webpack">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">

        <base href="/">
      </head>
      <body>
        <app>... Loading Universal ...</app>
        <script src="vendor.js"></script>
        <script src="main.js"></script>
      </body>
    </html>
    `,
    directives: [App],
    providers: [
      provide(REQUEST_URL, {useValue: url}),
      ...NODE_ROUTER_PROVIDERS,
      ...NODE_HTTP_PROVIDERS
    ]
  };

  bootloader.serializeApplication(APP_CONFIG)
  .then(html => res.send(html));
};
開發者ID:drejohnson,項目名稱:universal-angular2-starter,代碼行數:35,代碼來源:app.ts

示例2: generateHtml

export function generateHtml(opts: Options): Promise<string> {
    opts = Object.assign({
        originUrl: "http://localhost:8080",
        baseUrl: "/",
        reqUrl: "/",
        preboot: false,
    }, opts);

    let config: CliBootloaderConfig = {
        directives: [opts.component],
        platformProviders: [
            provide(ORIGIN_URL, { useValue: opts.originUrl }),
            provide(BASE_URL, { useValue: opts.baseUrl }),
        ],
        providers: [
            provide(REQUEST_URL, { useValue: opts.reqUrl }),
            ...NODE_ROUTER_PROVIDERS,
            ...NODE_HTTP_PROVIDERS,
        ],
        beautify: true,
        async: true,
    };

    enableProdMode();
    let doc = Bootloader.parseDocument(opts.templateHtml);
    config.document = doc;
    config.template = opts.templateHtml;
    config.preboot = opts.preboot;

    let bootloader = new Bootloader(config);
    return bootloader.serializeApplication();
}
開發者ID:gdi2290,項目名稱:ng-ssr-cli,代碼行數:32,代碼來源:index.ts

示例3: ngApp

function ngApp(req, res) {
  let url = req.originalUrl || '/';

  bootloader.serializeApplication(null, [
    provide(REQUEST_URL, {useValue: url}),
    ...NODE_ROUTER_PROVIDERS,
    ...NODE_HTTP_PROVIDERS
  ])
  .then(html => res.send(html));
};
開發者ID:drejohnson,項目名稱:universal-starter,代碼行數:10,代碼來源:server.ts

示例4: callback

 compiler.plugin('emit', (compilation, callback) => {
   if (compilation.assets.hasOwnProperty(this.options.templatePath)) {
     this.bootloader.serializeApplication({
       // or provide template in config.template
       template: compilation.assets[this.options.templatePath].source(), 
       directives: this.options.appConfig.directives,
       providers: this.options.appConfig.providers
     })
     .then(html => {
       compilation.assets[this.options.templatePath] = {
         source: () => html,
         size: () => html.length
       };
       callback();
     });
   }      
 });
開發者ID:krishnumorla,項目名稱:universal,代碼行數:17,代碼來源:prerender.ts

示例5: ngApp

export function ngApp(req, res) {
  let url = req.originalUrl || '/';

  const AppConfig = {
    templateUrl: 'main.html',
    directives: [AppComponent],
    providers: [
      {provide: REQUEST_URL, useValue: url},
      provideRouter(routes),
      ...NODE_HTTP_PROVIDERS,
      ...NODE_LOCATION_PROVIDERS
    ]
  };

  bootloader.serializeApplication(AppConfig)
  .then(html => res.send(html));
}
開發者ID:drejohnson,項目名稱:universal-starter-app,代碼行數:17,代碼來源:main.node.ts

示例6: queryParamsToBoolean

export const ngApp = (req, res) => {
  let baseUrl = '/';
  let url = req.originalUrl || '/';

  let queryParams: any = queryParamsToBoolean(req.query);
  let bootloader = new Bootloader({
    template: `
    <!doctype html>
    <html>
      <head>
        <title>Angular 2 Universal Starter</title>
        <meta charset="UTF-8">
        <meta name="description" content="Angular 2 Universal">
        <meta name="keywords" content="Angular 2,Universal">
        <meta name="author" content="PatrickJS">

        <link rel="icon" href="data:;base64,iVBORw0KGgo=">

        <base href="/">
      </head>
      <body>
        <app>... Loading Universal ...</app>
        <script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
        <script src="/main.js"></script>
      </body>
    </html>
    `,
    directives: [ App ],
    providers: [
      provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
      provide(BASE_URL, {useValue: baseUrl}),
      provide(REQUEST_URL,  { useValue: 'req.originalUrl' }),
      NODE_ROUTER_PROVIDERS,
      NODE_HTTP_PROVIDERS
    ],
    async: queryParams.async === false ? false : true,
    preboot: queryParams.preboot === false ? null : {debug: true, uglify: false}
  });

  bootloader.serializeApplication()
    .then(html => res.send(html));
};
開發者ID:gdi2290,項目名稱:universal-angular2-starter,代碼行數:42,代碼來源:app.ts

示例7: serialize

export function serialize(bootloader: Bootloader, template: string) : string {
  appConfig.template = template;
  return bootloader.serializeApplication(appConfig);
}
開發者ID:jeffbcross,項目名稱:webpack-mobile-test,代碼行數:4,代碼來源:main-app-shell.ts


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