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

Example

@Component(selector: 'child-cmp', template: '{{where}} child')
class ChildComponent {
  @Input()
  String where;
}
 
@Component(selector: 'parent-cmp', template: '<ng-content></ng-content>')
class ParentComponent implements AfterContentChecked {
  @ContentChild(ChildComponent)
  ChildComponent contentChild;
 
  ParentComponent() {
    // contentChild is not initialized yet
    print(_message(contentChild));
  }
 
  @override
  ngAfterContentChecked() {
    // contentChild is updated after the content has been checked
    print('AfterContentChecked: ${_message(contentChild)}');
  }
 
  String _message(cmp: ChildComponent) =>
      cmp  == null ? 'no child' : '${cmp.where} 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: const [NgIf, ParentComponent, ChildComponent]
)
export class App {
  bool hasContent = true;
}
 
bootstrap(App);

Constructors

AfterContentChecked()

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

ngAfterContentChecked() → dynamic

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() → String

Returns a string representation of this object.

inherited