Angular 2中的OnChanges和DoCheck有什么区别? [英] What is the difference between OnChanges and DoCheck in Angular 2?
本文介绍了Angular 2中的OnChanges和DoCheck有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
他们之间的差异对我来说似乎很混乱. 它们之间的区别以及确切的称呼时间
Difference between them seems to be very confusing to me. What is difference between them and exactly when they are called
推荐答案
-
当绑定到输入的值发生更改时,将调用
-
ngOnChanges()
(OnChanges
),以便在输入更改时可以运行自定义代码.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
),因此您可以实施自定义更改检测操作.ngDoCheck()
(DoCheck
) is called when change detection runs so you can implement your custom change detection action.这篇关于Angular 2中的OnChanges和DoCheck有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文