Jake
Jake

Reputation: 422

angular 1.5 $onChanges

So prior to the lifeCycle hook $onChanges I would use $scope.watch to track changes. After creating these watchers I would have to remove in order to keep my scope clean and avoid memory leaks. I was wondering if a similar manual clean up is required when using 1.5's $onChanges lifeCycle hook or since it is a lifeCycle hook it gets automatically taken care of when the component is destroyed.

thanks

Upvotes: 1

Views: 227

Answers (2)

Divyanshu Maithani
Divyanshu Maithani

Reputation: 14986

Angular manages the life cycle of a component itself. From the documentation itself,

Angular creates it, renders it, creates and renders its children, checks it when its data-bound properties change, and destroys it before removing it from the DOM.

The lifecycle is pretty much the same in 1.5 so $onChanges lifecycle hook will be taken care automatically when the component is destroyed.

Upvotes: 1

LD Robillard
LD Robillard

Reputation: 434

$onChanges is get deleted on destroy by itself. No need to manualy do it.

Upvotes: 1

Related Questions