Skip to content

Commit f085a7f

Browse files
committed
fix(portal): detect changes for portal hostview while before attaching.
1 parent 525ce1e commit f085a7f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/lib/core/portal/dom-portal-host.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,17 @@ export class DomPortalHost extends BasePortalHost {
2929
*/
3030
attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T> {
3131
let componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
32-
let componentRef: ComponentRef<T>;
32+
let componentRef = componentFactory.create(portal.injector || this._defaultInjector);
33+
//componentRef.hostView.detectChanges();
3334

3435
// If the portal specifies a ViewContainerRef, we will use that as the attachment point
3536
// for the component (in terms of Angular's component tree, not rendering).
3637
// When the ViewContainerRef is missing, we use the factory to create the component directly
3738
// and then manually attach the view to the application.
3839
if (portal.viewContainerRef) {
39-
componentRef = portal.viewContainerRef.createComponent(
40-
componentFactory,
41-
portal.viewContainerRef.length,
42-
portal.injector || portal.viewContainerRef.parentInjector);
43-
40+
portal.viewContainerRef.insert(componentRef.hostView);
4441
this.setDisposeFn(() => componentRef.destroy());
4542
} else {
46-
componentRef = componentFactory.create(portal.injector || this._defaultInjector);
4743
this._appRef.attachView(componentRef.hostView);
4844
this.setDisposeFn(() => {
4945
this._appRef.detachView(componentRef.hostView);

0 commit comments

Comments
 (0)