Closed
Description
I'm submitting a ... (check one with "x")
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When you provide a service using useFactory
, ngOnDestroy
will never be called.
Expected behavior
Regardless of how you provide the service, ngOnDestroy
should get called if it is a method on the service.
Minimal reproduction of the problem with instructions
https://plnkr.co/edit/aUaz6ewyM3m5JorsAoCO?p=preview
- Open the console.
- Click the "Create Component" button one or many times
- After a 2 second delay the component will be destroyed, but no console output will be seen.
- If you replace
useFactory
withuseClass
the problem goes away and you'll see output.
What is the motivation / use case for changing the behavior?
There are many cases, main motivator is that this isn't intuitive.
Please tell us about your environment:
- Angular version: 2.4.8
- Browser: Chrome 56.0.2924.87
-
Language: TypeScript 2.0
-
Node (for AoT issues):
node --version
=
kemsky, seangwright, nook-ru, sgkazakov, dimakuba and 2 more