Reputation: 422
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
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
Reputation: 434
$onChanges
is get deleted on destroy by itself. No need to manualy do it.
Upvotes: 1