To dynamically create a component and attach it to a specific location in the view, you'd use the ______ along with ComponentFactoryResolver.
- ComponentLoader
- DynamicInjector
- ViewChild
- ViewContainerRef
To dynamically create and attach components in Angular, you use the ViewContainerRef along with ComponentFactoryResolver. ViewContainerRef provides access to the view where you want to insert the component, and ComponentFactoryResolver helps create and manage the component instance. ViewChild is a decorator used to access child components, but it's not directly related to creating components dynamically. ComponentLoader and DynamicInjector are not standard Angular concepts in this context.
Loading...
Related Quiz
- Which directive in Angular is used to add or remove an element from the DOM based on a condition?
- How can you configure the Angular CLI to generate components with inline templates and styles by default?
- When you want to avoid unnecessary change detection cycles for components with data that doesn't change, you can set their change detection strategy to ChangeDetectionStrategy.______.
- How can you achieve nested routing (child routes) within an Angular application?
- Change detection in Angular can be optimized by ensuring data structures are ________.