fix(ivy): destroy injector when module is destroyed (#27793)

Destroys the module's injector when an `NgModule` is destroyed which in turn calls the `ngOnDestroy` methods on the instantiated providers.

This PR resolves FW-739.

PR Close #27793
This commit is contained in:
Kristiyan Kostadinov
2019-01-16 20:35:56 +01:00
committed by Alex Rickabaugh
parent 2b9cc8503d
commit ab2bf83398
5 changed files with 50 additions and 49 deletions

View File

@ -213,6 +213,7 @@ export class DowngradeComponentAdapter {
}
registerCleanup() {
const testabilityRegistry = this.componentRef.injector.get(TestabilityRegistry);
const destroyComponentRef = this.wrapCallback(() => this.componentRef.destroy());
let destroyed = false;
@ -220,8 +221,7 @@ export class DowngradeComponentAdapter {
this.componentScope.$on('$destroy', () => {
if (!destroyed) {
destroyed = true;
this.componentRef.injector.get(TestabilityRegistry)
.unregisterApplication(this.componentRef.location.nativeElement);
testabilityRegistry.unregisterApplication(this.componentRef.location.nativeElement);
destroyComponentRef();
}
});