Get List of ALL current registered Components in Angular 9

1.3k views Asked by At

In angular 8, we could do this to get list of all registered components:

    //resolver is ComponentFactoryResolver
    const factories = Array.from(this.resolver['_factories'].values());

    //selector is used so that it will work in production build also
    const factoryClass:any = factories.find((x: any) => x.selector ===  "SOME SELECTOR"); 
    if(factoryClass && factoryClass.componentType != undefined){
          console.log("Component found=>",factoryClass.componentType);
    }
            

In angular 9 (when using Ivy), this.resolver['_factories'] is undefined.

I need list of all components including the module's componenets which is being imported from the current module.

This problem has been asked before in this question:

How to access _factories property from ComponentFactoryResolver in Angular9 which was available in Angular7?

0

There are 0 answers