AfterContentInit

export interface AfterContentInit

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

Implement this interface to get notified when your directive's content has been fully initialized.

Example (live demo)

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

Members

ngAfterContentInit()

Not Yet Documented