本文整理汇总了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));
示例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);
});
};
示例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
};
示例4: renderModuleFactory
previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
document: index,
url: route,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP)
]
})).then(html => writeFileSync(join(fullPath, 'index.html'), html));
示例5: function
return function (filePath, options, callback) {
renderModuleFactory(AppServerModuleNgFactory, {
document: fs.readFileSync(filePath).toString(),
url: options.req.url
}).then(string => {
callback(null, string);
});
};
示例6: it
it('InjectionToken ngInjectableDef works', done => {
renderModuleFactory(TokenAppModuleNgFactory, {
document: '<token-app></token-app>',
url: '/',
}).then(html => {
expect(html).toMatch(/>fromToken<\//);
done();
});
});
示例7: renderModuleFactory
app.engine('html', (_, options, callback) => {
renderModuleFactory(AppServerModuleNgFactory, {
// Our index.html
document: template,
url: options.req.url
}).then(html => {
callback(null, html);
});
});