AfterContentChecked

一个生命周期钩子,它会在默认的变更检测器对指令的所有内容完成了变更检查之后调用。

A lifecycle hook that is called after the default change detector has completed checking all content of a directive.

      
      interface AfterContentChecked {
  ngAfterContentChecked(): void
}
    

参见

方法

一个回调函数,会在默认的变更检测器对该指令下的所有内容完成了变更检测之后立即调用。

A callback method that is invoked immediately after the default change detector has completed checking all of the directive's content.

ngAfterContentChecked(): void
      
      ngAfterContentChecked(): void
    
参数

没有参数。

返回值

void

使用说明

下列代码展示了组件如何实现该接口,已定义它在检查后要执行的自定义功能。

The following snippet shows how a component can implement this interface to define its own after-check functionality.

@Component({selector: 'my-cmp', template: `...`}) class MyComponent implements AfterContentChecked { ngAfterContentChecked() { // ... } }
      
      @Component({selector: 'my-cmp', template: `...`})
class MyComponent implements AfterContentChecked {
  ngAfterContentChecked() {
    // ...
  }
}