AfterViewInit

export interface AfterViewInit

exported from angular2/core defined in angular2/src/core/linker/interfaces.ts (line 381)

Implement this interface to get notified when your component's view has been fully initialized.

Example (live demo)

@Component({selector: 'child-cmp', template: `{{where}} child`}) class ChildComponent { @Input() where: string; } @Component({ selector: 'parent-cmp', template: `<child-cmp where="view"></child-cmp>`, directives: [ChildComponent] }) class ParentComponent implements AfterViewInit { @ViewChild(ChildComponent) viewChild: ChildComponent; constructor() { // viewChild is not initialized yet console.log(this.getMessage(this.viewChild)); } ngAfterViewInit() { // viewChild is updated after the view has been initialized console.log('ngAfterViewInit: ' + this.getMessage(this.viewChild)); } private getMessage(cmp: ChildComponent): string { return cmp ? cmp.where + ' child' : 'no child'; } } @Component({ selector: 'app', template: `<parent-cmp></parent-cmp>`, directives: [ParentComponent] }) export class App { } bootstrap(App).catch(err => console.error(err));

Members

ngAfterViewInit()

Not Yet Documented