Change Detection means updating the DOM whenever data is changed. Angular provides two strategies for Change Detection. Default strategy onPush strategy In default strategy, whenever any data is mutated or changed, Angular will run change detector to update the DOM. In onPush strategy, Angular will only run change detector only when new reference is passed to @Input() data. To update the DOM with updated data, Angular provides its own change detector to each component, which is responsible to detect change and update the DOM. Let us say we have a MessageComponent as listed below: In addition, we are using MessageComponent inside AppComponent as below, Let us talk through the code: all we are doing is using MessageComponent as child inside AppComponent and setting value of person using the property binding. At this point on running the application, you will get name printed as output. Next, let us go ahead and update firstname property on the button click in AppComponent class below: As soon as we changed the property of mutable object P, Angular fires the change detector to make sure that the DOM (or view) is in sync with the model (in this case object p).


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

angular