import { Component, ComponentFactoryResolver, Injector } from '@angular/core'; import { StaticReflector } from '@angular/compiler'; @Component({ /* ... */ }) export class MyComponent { constructor( private resolver: ComponentFactoryResolver, private injector: Injector, private reflector: StaticReflector ) {} createDynamicComponent(typeName: string) { const type = this.reflector.getStaticType(typeName); if (!type) { throw new Error(`Component type "${typeName}" not found.`); } const factory = this.resolver.resolveComponentFactory(type); const componentRef = factory.create(this.injector); // ... } }In this example, we're using the StaticReflector to get the static type of a component given its string name. We then use this type to resolve the corresponding ComponentFactory using Angular's ComponentFactoryResolver. The @angular/compiler package provides the StaticReflector class.