Skip to content

Commit

Permalink
refactor: Remove ComponentFactoryResolver (#1401)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon <simon@aam-digital.com>
  • Loading branch information
Schottkyc137 and TheSlimvReal authored Aug 23, 2022
1 parent 8d4aedf commit 46fa295
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ComponentFactoryResolver,
ComponentRef,
Directive,
Input,
Expand Down Expand Up @@ -37,19 +36,15 @@ export class DisableEntityOperationDirective implements OnInit, OnChanges {
constructor(
private templateRef: TemplateRef<HTMLButtonElement>,
private viewContainerRef: ViewContainerRef,
private componentFactoryResolver: ComponentFactoryResolver,
private ability: EntityAbility,
private abilityService: AbilityService
) {
this.abilityService.abilityUpdated.subscribe(() => this.applyPermissions());
}

ngOnInit() {
const containerFactory = this.componentFactoryResolver.resolveComponentFactory(
DisabledWrapperComponent
);
this.wrapperComponent = this.viewContainerRef.createComponent(
containerFactory
DisabledWrapperComponent
);
this.wrapperComponent.instance.template = this.templateRef;
this.wrapperComponent.instance.text = this.text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ComponentFactoryResolver,
Directive,
Input,
OnChanges,
Expand All @@ -26,7 +25,6 @@ export class DynamicComponentDirective implements OnChanges {

constructor(
public viewContainerRef: ViewContainerRef,
private componentFactoryResolver: ComponentFactoryResolver,
private registry: ViewRegistry
) {}

Expand All @@ -40,15 +38,11 @@ export class DynamicComponentDirective implements OnChanges {
}

const component = this.registry.get(this.appDynamicComponent.component);
const componentFactory = this.componentFactoryResolver.resolveComponentFactory<OnInitDynamicComponent>(
component
);

this.viewContainerRef.clear();

const componentRef = this.viewContainerRef.createComponent<OnInitDynamicComponent>(
componentFactory
);
const componentRef =
this.viewContainerRef.createComponent<OnInitDynamicComponent>(component);
componentRef.instance.onInitFromDynamicConfig(
this.appDynamicComponent.config
);
Expand Down

0 comments on commit 46fa295

Please sign in to comment.