Skip to content

Commit 1dca81b

Browse files
authored
fix(detached-loader): detach loadWithFactory (#2260)
1 parent bcde284 commit 1dca81b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: nativescript-angular/common/detached-loader.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ export class DetachedLoader implements OnDestroy {
4949
}
5050

5151
public loadWithFactory<T>(factory: ComponentFactory<T>): ComponentRef<T> {
52-
return this.containerRef.createComponent(factory, this.containerRef.length, this.containerRef.injector, null);
52+
const componentRef = factory.create(this.containerRef.injector);
53+
this.appRef.attachView(componentRef.hostView);
54+
55+
this.disposeFunctions.push(() => {
56+
this.appRef.detachView(componentRef.hostView);
57+
componentRef.destroy();
58+
});
59+
return componentRef;
5360
}
5461
}

0 commit comments

Comments
 (0)