diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/shared/shared-custom-markup/dynamic-element.service.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts b/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts index e967e30ac..208dba721 100644 --- a/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts +++ b/client/src/app/shared/shared-custom-markup/dynamic-element.service.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { | 1 | import { |
2 | ApplicationRef, | 2 | ApplicationRef, |
3 | ComponentFactoryResolver, | ||
4 | ComponentRef, | 3 | ComponentRef, |
4 | createComponent, | ||
5 | EmbeddedViewRef, | 5 | EmbeddedViewRef, |
6 | Injectable, | 6 | Injectable, |
7 | Injector, | 7 | Injector, |
@@ -16,15 +16,17 @@ export class DynamicElementService { | |||
16 | 16 | ||
17 | constructor ( | 17 | constructor ( |
18 | private injector: Injector, | 18 | private injector: Injector, |
19 | private applicationRef: ApplicationRef, | 19 | private applicationRef: ApplicationRef |
20 | private componentFactoryResolver: ComponentFactoryResolver | ||
21 | ) { } | 20 | ) { } |
22 | 21 | ||
23 | createElement <T> (ofComponent: Type<T>) { | 22 | createElement <T> (ofComponent: Type<T>) { |
24 | const div = document.createElement('div') | 23 | const div = document.createElement('div') |
25 | 24 | ||
26 | const component = this.componentFactoryResolver.resolveComponentFactory(ofComponent) | 25 | const component = createComponent(ofComponent, { |
27 | .create(this.injector, [], div) | 26 | environmentInjector: this.applicationRef.injector, |
27 | elementInjector: this.injector, | ||
28 | hostElement: div | ||
29 | }) | ||
28 | 30 | ||
29 | return component | 31 | return component |
30 | } | 32 | } |