PlatformRef
interface
The Angular platform is the entry point for Angular on a web page. Each page has exactly one platform. Services (such as reflection) which are common to every Angular application running on the page are bound in its scope. A page's platform is initialized implicitly when a platform is created using a platform factory such as PlatformBrowser
, or explicitly by calling the createPlatform()
function.
interface PlatformRef {
injector: Injector
destroyed
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>, options?: BootstrapOptions): Promise<NgModuleRef<M>>
bootstrapModule<M>(moduleType: Type<M>, compilerOptions: (CompilerOptions & BootstrapOptions) | (CompilerOptions & BootstrapOptions)[] = []): Promise<NgModuleRef<M>>
onDestroy(callback: () => void): void
destroy()
}
Properties
Property | Description |
---|---|
injector: Injector
|
Read-Only Retrieves the platform Injector, which is the parent injector for every Angular application on the page and provides singleton providers. |
destroyed
|
Read-Only |
Methods
bootstrapModuleFactory() | ||||||
---|---|---|---|---|---|---|
Creates an instance of an @NgModule for the given platform for offline compilation.
| ||||||
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>, options?: BootstrapOptions): Promise<NgModuleRef<M>>Parameters
Returns
| ||||||
Usage NotesThe following example creates the NgModule for a browser platform.
|
bootstrapModule() | ||||||
---|---|---|---|---|---|---|
Creates an instance of an @NgModule for a given platform using the given runtime compiler.
| ||||||
bootstrapModule<M>(moduleType: Type<M>, compilerOptions: (CompilerOptions & BootstrapOptions) | (CompilerOptions & BootstrapOptions)[] = []): Promise<NgModuleRef<M>>Parameters
Returns
| ||||||
Usage NotesSimple Example
|
onDestroy() | |||
---|---|---|---|
Registers a listener to be called when the platform is destroyed. | |||
onDestroy(callback: () => void): voidParameters
Returns
|
destroy() |
---|
Destroys the current Angular platform and all Angular applications on the page. Destroys all modules and listeners registered with the platform. |
destroy()ParametersThere are no parameters.
|
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v10.angular.io/api/core/PlatformRef