ApplicationRef

export class ApplicationRef

exported from angular2/core defined in angular2/src/core/application_ref.ts (line 279)

A reference to an Angular application running on a page.

For more about Angular applications, see the documentation for bootstrap.

Members

registerBootstrapListener(listener: (ref: ComponentRef) => void) : void

Register a listener to be called each time bootstrap() is called to bootstrap a new root component.

registerDisposeListener(dispose: () => void) : void

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

bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>) : Promise<ComponentRef>

Bootstrap a new component at the root level of the application.

Bootstrap process

When bootstrapping a new root component into an application, Angular mounts the specified application component onto DOM elements identified by the [componentType]'s selector and kicks off automatic change detection to finish initializing the component.

Optional Providers

Providers for the given component can optionally be overridden via the providers parameter. These providers will only apply for the root component being added and any child components under it.

#

@Component({selector: 'my-app', template: 'Hello World'}) class MyApp { } var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, appProviders]); app.bootstrap(MyApp);

injector : Injector

Retrieve the application Injector.

zone : NgZone

Retrieve the application NgZone.

dispose() : void

Dispose of this application and all of its components.

tick() : void

Invoke this method to explicitly process change detection and its side-effects.

In development mode, tick() also performs a second change detection cycle to ensure that no further changes are detected. If additional changes are picked up during this second cycle, bindings in the app have side-effects that cannot be resolved in a single change detection pass. In this case, Angular throws an error, since an Angular application can only have one change detection pass during which all change detection must complete.

componentTypes : Type[]

Get a list of component types registered to this application.