@angular/platform-server#renderModuleFactory TypeScript Examples
The following examples show how to use
@angular/platform-server#renderModuleFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: prerender.ts From ng-event-plugins with Apache License 2.0 | 6 votes |
// Iterate each route path
PRERENDERED_ROUTES.forEach(route => {
const fullPath = join(DEMO_FOLDER, route);
// Make sure the directory structure is there
if (!existsSync(fullPath)) {
mkdirSync(fullPath);
}
// Writes rendered HTML to index.html, replacing the file if it already exists.
previousRender = previousRender
.then(() =>
renderModuleFactory(AppServerModuleNgFactory, {
document: index,
url: route,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{
provide: APP_BASE_HREF,
useValue: process.env.ORIGIN || localFallback,
},
],
}),
)
.then(html => writeFileSync(join(fullPath, 'index.html'), html));
});
Example #2
Source File: prerender.ts From fab-menu with MIT License | 6 votes |
// Iterate each route path
ROUTES.forEach(route => {
const fullPath = join(BROWSER_FOLDER, route);
// Make sure the directory structure is there
if (!existsSync(fullPath)) {
mkdirSync(fullPath);
}
// Writes rendered HTML to index.html, replacing the file if it already exists.
previousRender = previousRender
.then(_ =>
renderModuleFactory(AppServerModuleNgFactory, {
document: index,
url: route,
extraProviders: [provideModuleMap(LAZY_MODULE_MAP)]
})
)
.then(html => writeFileSync(join(fullPath, 'index.html'), html));
});