PlatformRef
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()
}
属性
属性 | 说明 |
---|---|
injector: Injector | 只读 Retrieves the platform |
destroyed | 只读 |
方法
Creates an instance of an | ||||||
参数
返回值
| ||||||
使用说明The following example creates the NgModule for a browser platform.
|
Creates an instance of an | ||||||
参数
返回值
| ||||||
使用说明Simple Example
|
Registers a listener to be called when the platform is destroyed. |
Destroys the current Angular platform and all Angular applications on the page. Destroys all modules and listeners registered with the platform. |
参数没有参数。 |