Skip to content

Commit b72dd99

Browse files
committed
[angular] Fix conditional update of component ref
1 parent 604ffef commit b72dd99

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/angular/src/jsonforms.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ export class JsonFormsOutlet extends JsonFormsBaseRenderer implements OnInit, On
9898
bestComponent = renderer.renderer;
9999
}
100100

101-
if (this.componentRef === undefined) {
102-
const componentFactory =
103-
this.componentFactoryResolver.resolveComponentFactory(bestComponent);
101+
const componentFactory =
102+
this.componentFactoryResolver.resolveComponentFactory(bestComponent);
103+
const component: ComponentRef<any> =
104+
this.viewContainerRef.createComponent(componentFactory);
105+
106+
if (this.componentRef === undefined ||
107+
this.componentRef.componentType !== component.componentType) {
104108
this.viewContainerRef.clear();
105109
this.componentRef = this.viewContainerRef.createComponent(componentFactory);
106110
}

0 commit comments

Comments
 (0)