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


TypeScript platform-server.renderModuleFactory函数代码示例

本文整理汇总了TypeScript中@angular/platform-server.renderModuleFactory函数的典型用法代码示例。如果您正苦于以下问题:TypeScript renderModuleFactory函数的具体用法?TypeScript renderModuleFactory怎么用?TypeScript renderModuleFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: renderModuleFactory

 prom = prom.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
   document: index,
   url: route,
   extraProviders: [
     provideModuleMap(LAZY_MODULE_MAP)
   ]
 })).then(html => writeFileSync(join(BROWSER_FOLDER, route, 'index.html'), html));
开发者ID:sebastienbarbier,项目名称:sebastienbarbier.com,代码行数:7,代码来源:prerender.ts

示例2: function

  return function (filePath: string, options: { req: Request }, callback: (err: Error, html: string) => void) {
    let url: string = options.req.url;
    let html: string = outputCache[url];
    if (html) {
      // return already-built page for this url
      console.log('from cache: ' + url);
      callback(null, html);
      return;
    }

    console.log('building: ' + url);
    if (!templateCache[filePath]) {
      let file = fs.readFileSync(filePath);
      templateCache[filePath] = file.toString();
    }

    // render the page via angular platform-server
    let appModuleFactory = setupOptions.bootstrap[0];
    renderModuleFactory(appModuleFactory, {
      document: templateCache[filePath],
      url: url
    }).then(str => {
      outputCache[url] = str;
      callback(null, str);
    });
  };
开发者ID:DanielKucal,项目名称:angular,代码行数:26,代码来源:universal-engine.ts

示例3: function

  return function (
    filePath: string,
    options: { req: Request },
    callback: (err: Error, html: string) => void) {

    const { req } = options;
    const routeUrl = req.url;

    let template = templateCache[filePath];
    if (!template) {
      template = fs.readFileSync(filePath).toString();
      templateCache[filePath] = template;
    }

    const { appModuleFactory } = setupOptions;
    const origin = getOrigin(req);

    // #docregion render
    // render the page
    renderModuleFactory(appModuleFactory, {
      document: template,
      url: routeUrl,
      extraProviders: [
        { provide: APP_BASE_HREF, useValue: origin }
      ]
    })
    .then(page => callback(null, page));
    // #enddocregion render
  };
开发者ID:cartant,项目名称:angular,代码行数:29,代码来源:universal-engine.ts

示例4: renderModuleFactory

 previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
   document: index,
   url: route,
   extraProviders: [
     provideModuleMap(LAZY_MODULE_MAP)
   ]
 })).then(html => writeFileSync(join(fullPath, 'index.html'), html));
开发者ID:nacardin,项目名称:monicawulaw-website,代码行数:7,代码来源:prerender.ts

示例5: function

 return function (filePath, options, callback) {
   renderModuleFactory(AppServerModuleNgFactory, {
     document: fs.readFileSync(filePath).toString(),
     url: options.req.url
   }).then(string => {
     callback(null, string);
   });
 };
开发者ID:hitpopdimestop,项目名称:universal-test,代码行数:8,代码来源:main.server.ts

示例6: it

 it('InjectionToken ngInjectableDef works', done => {
   renderModuleFactory(TokenAppModuleNgFactory, {
     document: '<token-app></token-app>',
     url: '/',
   }).then(html => {
     expect(html).toMatch(/>fromToken<\//);
     done();
   });
 });
开发者ID:robwormald,项目名称:angular,代码行数:9,代码来源:app_spec.ts

示例7: renderModuleFactory

app.engine('html', (_, options, callback) => {
  renderModuleFactory(AppServerModuleNgFactory, {
    // Our index.html
    document: template,
    url: options.req.url
  }).then(html => {
    callback(null, html);
  });
});
开发者ID:marffox,项目名称:flex-layout,代码行数:9,代码来源:server.ts


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