class
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.
class 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()
} | Property | Description |
|---|---|
injector: Injector |
Read-Only Retrieves the platform |
destroyed | Read-Only |
| bootstrapModuleFactory() | ||||||
|---|---|---|---|---|---|---|
| Creates an instance of an | ||||||
|
moduleFactory | NgModuleFactory | |
options | BootstrapOptions | Optional. Default is |
Promise<NgModuleRef<M>>
The following example creates the NgModule for a browser platform.
my_module.ts:
@NgModule({
imports: [BrowserModule]
})
class MyModule {}
main.ts:
import {MyModuleNgFactory} from './my_module.ngfactory';
import {platformBrowser} from '@angular/platform-browser';
let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory); | bootstrapModule() | ||||||
|---|---|---|---|---|---|---|
| Creates an instance of an | ||||||
|
moduleType | Type | |
compilerOptions | (CompilerOptions & BootstrapOptions) | (CompilerOptions & BootstrapOptions)[] | Optional. Default is |
Promise<NgModuleRef<M>>
@NgModule({
imports: [BrowserModule]
})
class MyModule {}
let moduleRef = platformBrowser().bootstrapModule(MyModule); | onDestroy() | |||
|---|---|---|---|
| Registers a listener to be called when the platform is destroyed. | |||
|
callback | () => void |
void
| destroy() |
|---|
| Destroys the current Angular platform and all Angular applications on the page. Destroys all modules and listeners registered with the platform. |
|
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/core/PlatformRef