Skip to content

Commit

Permalink
Add elementInjector to dynamically created dialog component (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatta authored Apr 9, 2024
1 parent fb16ca4 commit b86cc7d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
ApplicationRef,
createComponent,
EnvironmentInjector,
createEnvironmentInjector
createEnvironmentInjector,
Injector
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { CpsDialogRef } from './utils/cps-dialog-ref';
Expand All @@ -28,6 +29,7 @@ export class CpsDialogService {
constructor(
private _appRef: ApplicationRef,
private _environmentInjector: EnvironmentInjector,
private _injector: Injector,
@Inject(DOCUMENT) private document: Document
) {}

Expand Down Expand Up @@ -102,7 +104,11 @@ export class CpsDialogService {
{ provide: CpsDialogRef, useValue: dialogRef }
],
this._environmentInjector
)
),
elementInjector:
this._injector !== this._environmentInjector
? this._injector
: undefined
});

this._appRef.attachView(componentRef.hostView);
Expand Down

0 comments on commit b86cc7d

Please sign in to comment.