We're a place where coders share, stay up-to-date and grow their careers.
What do u think . If I use a subscribe in service?
There's no problem with that. Services have ngOnDestroy hook as well. You can use it for clean up. coryrylan.com/blog/using-ngondestr...
ngOnDestroy
That's good advice. Just don't try to use ngOnInit. It doesn't work for services. Instead, use the service constructor or an Angular initializer.
What do u think . If I use a subscribe in service?
There's no problem with that. Services have
ngOnDestroy
hook as well. You can use it for clean up. coryrylan.com/blog/using-ngondestr...That's good advice. Just don't try to use ngOnInit. It doesn't work for services. Instead, use the service constructor or an Angular initializer.