Current behavior
export class DestroyTest implements OnDestroy {
ngOnDestroy() { // <<<<< this method is NEVER called
console.log('ngOnDestroy DestroyTest called');
}
}
export class DestroyTest2 implements OnDestroy {
ngOnDestroy() { // <<<<< this method IS called when the app ref is being destroyed
console.log('ngOnDestroy DestroyTest2 called');
}
}
export function createDestroyTest() {
return new DestroyTest();
}
@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent, HelloComponent ],
bootstrap: [ AppComponent ],
providers: [
{provide: DestroyTest, useFactory: createDestroyTest},
DestroyTest2
]
})
export class AppModule {
constructor(
destroyTest1: DestroyTest, destroyTest2: DestroyTest2) {}
}
Expected behavior
the ngOnDestroy method, if present, should be called on all values provided via DI regardless of the provider type.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-h15slp
Environment
Angular version: 6.0.0-beta.x
// Note: reported by GX
Current behavior
Expected behavior
the
ngOnDestroymethod, if present, should be called on all values provided via DI regardless of the provider type.Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-h15slp
Environment
// Note: reported by GX