Angular ngAfterContentChecked()不可理解+;角度2

Angular ngAfterContentChecked()不可理解+;角度2,angular,angular2-forms,angular2-services,Angular,Angular2 Forms,Angular2 Services,一段时间以来,我一直在试图弄清ngAfterContentChecked()和ngAfterViewChecked()的含义。我试过各种帖子,但仍然无法理解它们的确切含义。以下是angular.io中给出的定义。 有人能用一些好的例子恰当地解释一下吗 ngAfterViewChecked()- Respond after Angular checks the component's views and child views. Called after the ngAfterViewInit a

一段时间以来,我一直在试图弄清
ngAfterContentChecked()
ngAfterViewChecked()
的含义。我试过各种帖子,但仍然无法理解它们的确切含义。以下是angular.io中给出的定义。 有人能用一些好的例子恰当地解释一下吗

ngAfterViewChecked()- Respond after Angular checks the component's views and child views.
Called after the ngAfterViewInit and every subsequent ngAfterContentChecked().
A component-only hook.

ngAfterContentChecked()- Respond after Angular checks the content projected into the component.
Called after the ngAfterContentInit() and every subsequent ngDoCheck().
A component-only hook.

假设我们有这个Html

<div> // div A
  <app-my-component>
    <div>
      this is some content for the component app-my-component
    </div>
  </app-my-component>
</div> // div B
//div A
这是组件应用程序my component的一些内容
//B组
假设我们有这个组件

@Component({
  selector: 'app-my-component',
  template: `
    <div> // div C
      here is the View HTML but below we receive content html
      <ng-content></ng-content>
    </div> // div D
  `
})
@组件({
选择器:“应用程序我的组件”,
模板:`
//C组
这里是查看HTML,但下面我们接收内容HTML
//D组
`
})
在我们的组件中,从A部分一直到B部分,这就是视图。所以AfterViewChecked将在我们到达B时运行。内容是ng内容标签中的所有内容。因此,AfterContentChecked将在我们到达div D时运行。但是,对视图的任何更改都会触发额外的AfterViewCheck,这也会触发AfterContentCheck