当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Bootloader.create方法代码示例

本文整理汇总了TypeScript中angular2-universal.Bootloader.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Bootloader.create方法的具体用法?TypeScript Bootloader.create怎么用?TypeScript Bootloader.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2-universal.Bootloader的用法示例。


在下文中一共展示了Bootloader.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

AppShellPlugin.prototype.build = function () {
  var sourceHtml = fse.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
  var options = {
    document: Bootloader.parseDocument(sourceHtml),
    directives: [ IssueCliApp ],
    providers: [
      provide(APP_BASE_HREF, {useValue: '/'}),
      provide(REQUEST_URL, {useValue: '/'}),
      provide(IS_POST_LOGIN, {
        useValue: false
      }),
      ROUTER_PROVIDERS,
      NODE_LOCATION_PROVIDERS,
      provide(IS_PRERENDER, {
        useValue: true
      }),
      FIREBASE_PROVIDERS,
      NODE_HTTP_PROVIDERS,
      provide(LOCAL_STORAGE, {
        useValue: {
          getItem: () => null,
          setItem: () => null
        }
      }),
      defaultFirebase('https://issue-zero.firebaseio.com')
    ],
    preboot: false
  }

    var bootloader = Bootloader.create(options);
    return bootloader.serializeApplication().then(html =>  fse.outputFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
}
开发者ID:QuinntyneBrown,项目名称:issue-zero,代码行数:32,代码来源:broccoli-app-shell.ts

示例2: bootstrap

export function bootstrap(appComponentType: any, appProviders: Array<Type | Provider | any | any[]> = []): Promise<ComponentRef<any>> {
  let combinedProviders = [
    IOT_PROVIDERS,
    ...appProviders
  ];
  const bootloader = Bootloader.create({
    providers: combinedProviders
  });
  return bootloader.bootstrap(appComponentType);
}
开发者ID:WildGenie,项目名称:angular2-iot,代码行数:10,代码来源:index.ts

示例3: build

 build() {
   var sourceHtml = fs.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
   var appShellOptions = require(path.resolve(this.inputPaths[0], this.appShellPath)).options;
   var options = Object.assign(appShellOptions, {
     document: Bootloader.parseDocument(sourceHtml),
   });
   var bootloader = Bootloader.create(options);
   return bootloader.serializeApplication()
     .then(html =>  fs.writeFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
 }
开发者ID:axwl,项目名称:universal,代码行数:10,代码来源:prerender.ts

示例4: build

 build() {
   var sourceHtml = fs.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
   var appShellOptions = require(path.resolve(this.inputPaths[0], this.appShellPath)).options;
   var options = Object.assign(appShellOptions, {
     document: Bootloader.parseDocument(sourceHtml),
   });
   var bootloader = Bootloader.create(options);
   // Make sure to get all providers and platformProviders
   var providers = [].concat(options.providers || []).concat(options.platformProviders || []);
   return bootloader.serializeApplication(null, providers)
     .then(html =>  fs.writeFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
 }
开发者ID:laskoviymishka,项目名称:universal,代码行数:12,代码来源:prerender.ts

示例5: render

  static render(component) {
    let url = this.getCurrentUrl();
    let options = this.getUniOptions(component, '/', url);

    let bootloader = Bootloader.create(options);
    let serialize = bootloader.serializeApplication();
    let html = null;
    new Promise(function(resolve, reject) {
      serialize.then(result => {
        html = result;
        resolve();
      }, reject);
    }).await();

    let router = this.getRouter();
    if (router) {
      var ssrContext = router.ssrContext.get();
      ssrContext.setHtml(html);
    }

    return html;
  }
开发者ID:barbatus,项目名称:ng2-todo-ssr,代码行数:22,代码来源:ng2-ssr.ts

示例6: require

import 'angular2-universal-polyfills';
import {Bootloader} from 'angular2-universal';
import { disposePlatform } from '@angular/core';
const fs = require('fs');
const path = require('path');
const args = require('optimist').argv;
const appShellOptions = require(args.optionsPath).options;
const sourceHtml = fs.readFileSync(args.sourceHtml, 'utf-8');

var options = Object.assign(appShellOptions, {
  document: Bootloader.parseDocument(sourceHtml),
});
var bootloader = Bootloader.create(options);
// Make sure to get all providers and platformProviders
var providers = [].concat(options.providers || []).concat(options.platformProviders || []);
bootloader.serializeApplication(null, providers)
  .then(html =>  fs.writeFileSync(args.outputIndexPath, html, 'utf-8'))
  .then(() => process.exit(0))
  .catch(e => {
    if (e) console.error(e);
    process.exit(1);
  });
开发者ID:An0564,项目名称:universal,代码行数:22,代码来源:child_proc.ts


注:本文中的angular2-universal.Bootloader.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。