Complete the code to import the Angular core module needed for dynamic component loading.
import { [1] } from '@angular/core';
The ComponentFactoryResolver is used to create component factories for dynamic loading.
Complete the code to get a reference to the container where the dynamic component will be inserted.
@ViewChild('container', { read: [1] }) containerRef!: ViewContainerRef;
ViewContainerRef is needed to insert components dynamically into the view.
Fix the error in the code to create a component dynamically using the resolver.
const factory = this.componentFactoryResolver.[1](MyDynamicComponent);
this.containerRef.clear();
this.containerRef.createComponent(factory);The correct method to get a component factory is resolveComponentFactory.
Fill both blanks to clear the container and insert the new component.
this.containerRef.[1](); this.containerRef.[2](factory);
First, clear the container with clear(), then create the component with createComponent().
Fill all three blanks to define a dynamic component loader method that creates and inserts a component.
loadComponent() {
const factory = this.[1].[2](DynamicComponent);
this.containerRef.[3]();
this.containerRef.createComponent(factory);
}The method uses componentFactoryResolver to get the factory, calls resolveComponentFactory, then clears the container before creating the component.