📜  onchanges vs docheck - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:55.631000             🧑  作者: Mango

代码示例1
Comparison
- ngOnChanges() (OnChanges) is called when a value bound to an input has changed so you can run custom code when an input has changed.
- ngDoCheck() (DoCheck) is called when change detection runs so you can implement your custom change detection action.

Change detection can run for reasons other than inputs being changes. 
Reasons such as native events, XHR, etc...