ApplicationRef

Stable Class

Class Overview

class ApplicationRef {
  bootstrap(componentFactory: ComponentFactory<C>|Type<C>) : ComponentRef<C>
  tick() : void
  componentTypes : Type<any>[]
  components : ComponentRef<any>[]
}

Class Description

A reference to an Angular application running on a page.

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

Class Details

bootstrap(componentFactory: ComponentFactory<C>|Type<C>) : ComponentRef<C>

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.

@Component({selector: 'my-app', template: 'Hello World'})
class MyApp {
}

var myPlatformFactory = createPlatformFactory(platformBrowserDynamic, 'myPlatform');
myPlatformFactory().bootstrapModule(MyApp);
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<any>[]

Get a list of component types registered to this application. This list is populated even before the component is created.

components : ComponentRef<any>[]

Get a list of components registered to this application.

exported from @angular/core/index, defined in @angular/core/src/application_ref.ts

doc_Angular
2016-10-06 09:46:15
Comments
Leave a Comment

Please login to continue.