Skip to content

Instantly share code, notes, and snippets.

@zankooh
zankooh / app-component-registry.ts
Created December 25, 2020 09:15 — forked from arniebradfo/app-component-registry.ts
Get a Angular component by a string corresponding to its class name
/**
* @author http://bradford.digital
* @link https://stackoverflow.com/questions/42949647/resolve-type-of-component-from-string-in-angular2
*
* Keep a registry of key:value pairs that is the string name of a component and the Component reference
* The registry is stored in an exported const named COMPONENTREGISTRY
* Add to the registry by using the registerComponent() function as an adorner. example:
* @registerComponent
* @Component({...})
* export class AnExampleComponent {...}