Skip to content

Commit 68f5844

Browse files
committed
fix: re-render when nested dynamic component
1 parent ec9a06a commit 68f5844

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

projects/toppy/src/lib/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ng-container *ngTemplateOutlet="content.data; context: { $implicit: content.props }"></ng-container>
1010
</ng-container>
1111
<ng-container *ngSwitchCase="'c'">
12-
<ng-container *ngComponentOutlet="content.data; injector: createInj()"></ng-container>
12+
<ng-container *ngComponentOutlet="content.data; injector: overlayInj || createInj"></ng-container>
1313
</ng-container>
1414
</ng-container>
1515
</div>

projects/toppy/src/lib/toppy.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class ToppyComponent implements OnInit, AfterViewInit, OnDestroy {
3434
el: HTMLElement | any;
3535
wrapperEl: HTMLElement | any;
3636
extra: string;
37+
overlayInj: Injector = null;
3738
private die: Subject<1> = new Subject();
3839

3940
constructor(private inj: Injector, private cd: ChangeDetectorRef, private elRef: ElementRef) {}
@@ -54,15 +55,16 @@ export class ToppyComponent implements OnInit, AfterViewInit, OnDestroy {
5455
this.listenPos().subscribe();
5556
}
5657

57-
createInj(): Injector {
58-
return newInjector(
58+
get createInj(): Injector {
59+
this.overlayInj = newInjector(
5960
{
6061
provide: ToppyOverlay,
6162
useFactory: () => new ToppyOverlay(this.content.props),
6263
deps: []
6364
},
6465
this.inj
6566
);
67+
return this.overlayInj;
6668
}
6769

6870
updateTextContent(data: string): void {

0 commit comments

Comments
 (0)