AfterContentChecked

export interface AfterContentChecked

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

Implement this interface to get notified after every check of your directive's content.

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 AfterContentChecked { @ContentChild(ChildComponent) contentChild: ChildComponent; constructor() { // contentChild is not initialized yet console.log(this.getMessage(this.contentChild)); } ngAfterContentChecked() { // contentChild is updated after the content has been checked console.log('AfterContentChecked: ' + this.getMessage(this.contentChild)); } private getMessage(cmp: ChildComponent): string { return cmp ? cmp.where + ' child' : 'no child'; } } @Component({ selector: 'app', template: ` <parent-cmp> <button (click)="hasContent = !hasContent">Toggle content child</button> <child-cmp *ngIf="hasContent" where="content"></child-cmp> </parent-cmp>`, directives: [NgIf, ParentComponent, ChildComponent] }) export class App { hasContent = true; } bootstrap(App).catch(err => console.error(err));

Members

ngAfterContentChecked()

Not Yet Documented