Angular 什么时候触发 ngAfterContentChecked?

When does Angular trigger ngAfterContentChecked?

根据 the docs AfterContentChecked 生命周期挂钩被触发:

after Angular checks the content projected into the component

文档中的 "Angular checks" 到底是什么意思?

AfterContentChecked,仅组件挂钩,在 Angular 检查投射到组件的内容(它的数据绑定属性)之后调用。

Angular什么时候检查投影内容?

  • 最初,在 AfterContentInit 挂钩完成后。
  • 每次变化检测都是运行(应用状态变化)

什么导致应用程序状态改变?

  • 事件 - 点击,提交,...
  • Ajax 调用 - 从远程服务器获取数据
  • 计时器 - setTimeout、setInterval

另请参阅:Angular change detection explained