當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。