What is ComponentFactoryResolver used for?

880    Asked by RebeccaKing in Python , Asked on Jan 20, 2020
Answered by Rebecca King

A class that is used to create dynamic components - it produces a ComponentFactory for a particular component which can then be loaded into view via a createComponent on ViewContainerRef. Use ComponentFactoryResolver and ViewContainerRef to create the specific component needed and display it inside DetailsComponent.

const componentRef: any = this.componentFactoryResolver

  .resolveComponentFactory(component)

  .create(this.injector);

componentRef.instance.productId = data.productId;



Your Answer

Interviews

Parent Categories