AfterViewChecked

一个生命周期钩子,它会在默认的变更检测器完成了对组件视图的变更检测之后调用。

A lifecycle hook that is called after the default change detector has completed checking a component's view for changes.

      
      interface AfterViewChecked {
  ngAfterViewChecked(): void
}
    

参见

方法

一个回调方法,它会在默认的变更检测器对组件视图完成了一轮变更检测周期之后立即调用。

A callback method that is invoked immediately after the default change detector has completed one change-check cycle for a component's view.

ngAfterViewChecked(): void
      
      ngAfterViewChecked(): 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 AfterViewChecked { ngAfterViewChecked() { // ... } }
      
      @Component({selector: 'my-cmp', template: `...`})
class MyComponent implements AfterViewChecked {
  ngAfterViewChecked() {
    // ...
  }
}