Skip to content

Commit

Permalink
fix(detached-loader): detach loadWithFactory (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
edusperoni committed Sep 21, 2020
1 parent bcde284 commit 1dca81b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nativescript-angular/common/detached-loader.ts
Expand Up @@ -49,6 +49,13 @@ export class DetachedLoader implements OnDestroy {
}

public loadWithFactory<T>(factory: ComponentFactory<T>): ComponentRef<T> {
return this.containerRef.createComponent(factory, this.containerRef.length, this.containerRef.injector, null);
const componentRef = factory.create(this.containerRef.injector);
this.appRef.attachView(componentRef.hostView);

this.disposeFunctions.push(() => {
this.appRef.detachView(componentRef.hostView);
componentRef.destroy();
});
return componentRef;
}
}

0 comments on commit 1dca81b

Please sign in to comment.