PlatformRef

class

npm Package @angular/core
Module import { PlatformRef } from '@angular/core';
Source core/src/application_ref.ts

Overview

class PlatformRef {
  bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>>
  bootstrapModule<M>(moduleType: Type<M>, compilerOptions?: CompilerOptions|CompilerOptions[]): Promise<NgModuleRef<M>>
  onDestroy(callback: () => void): void
  get injector: Injector
  destroy(): void
  get destroyed: boolean
}

Description

The Angular platform is the entry point for Angular on a web page. Each page has exactly one platform, and 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 via a platform factory (e.g. platformBrowser), or explicitly by calling the createPlatform function.

Members

bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>>

Creates an instance of an @NgModule for the given platform for offline compilation.

Simple Example

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<M>(moduleType: Type<M>, compilerOptions?: CompilerOptions|CompilerOptions[]): Promise<NgModuleRef<M>>

Creates an instance of an @NgModule for a given platform using the given runtime compiler.

Simple Example

@NgModule({
  imports: [BrowserModule]
})
class MyModule {}

let moduleRef = platformBrowser().bootstrapModule(MyModule);

onDestroy(callback: () => void): void

Register a listener to be called when the platform is disposed.

get injector: Injector

Retrieve the platform Injector, which is the parent injector for every Angular application on the page and provides singleton providers.

destroy(): void

Destroy the Angular platform and all Angular applications on the page.

get destroyed: boolean

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/PlatformRef