When dynamically creating a component, which object is responsible for providing the factory to create an instance of the component?
- ComponentFactoryResolver
- ElementRef
- NgModule
- ViewChild
The ComponentFactoryResolver is responsible for providing the factory to create an instance of a component dynamically in Angular. It's a crucial part of dynamic component creation, allowing you to create components on the fly based on specific conditions or requirements in your application. NgModule deals with module-level configuration, ViewChild is used for querying child components, and ElementRef is used for accessing the DOM element of a component, but none of these directly provide a factory for dynamic component creation.
Loading...
Related Quiz
- In Angular's routing, which guard determines whether a module can be lazily loaded?
- What command would you use to generate a new module and its associated routing in a single command using Angular CLI?
- What should you do to ensure that an HTTP request is unsubscribed automatically when a component is destroyed?
- Which method of the ControlValueAccessor interface is called when the form control value changes programmatically?
- Which Angular decorator is used to define a component's metadata?