On this page
renderApplication
function
developer preview
Bootstraps an instance of an Angular application and renders it to a string.
renderApplication<T>(rootComponent: Type<T>, options: { appId: string; document?: string | Document; url?: string; providers?: (Provider | ImportedNgModuleProviders)[]; platformProviders?: Provider[]; }): Promise<string>
Parameters
rootComponent |
Type<T> |
A reference to a Standalone Component that should be rendered. |
options |
object |
Additional configuration for the render operation:
|
Returns
Promise<string>
: A Promise, that returns serialized (to a string) rendered page, once resolved.
Description
Note: the root component passed into this function must be a standalone one (should have the standalone: true
flag in the @Component
decorator config).
@Component({
standalone: true,
template: 'Hello world!'
})
class RootComponent {}
const output: string = await renderApplication(RootComponent, {appId: 'server-app'});
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v14.angular.io/api/platform-server/renderApplication