DEV Community

Discussion on: When a service got destroyed in angular

Collapse
 
bo profile image
Bo Vandersteene

My articles is about services so providers and not directives. So the conclusion is for using ngOnDestroy on a service and NOT on a directive

Thread Thread
 
hp13055 profile image
F.1.armchair.expert • Edited

I've read the article again. You open it with
"If we read the OnDestroy lifecycle hook api description Angular OnDestroy we can use it on services."
But, how do you came to that conclusion? The lifecycle is described for components and directives. Where do you read it could be used on sercices?
You may have misunderstood whats written for onDestroy(). Services are mentioned there, right, but its meant as example to use onDestroy on your component to unregister it from(!) services.