question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a service to find component by name

See original GitHub issue

🚀 feature request

Relevant Package

This feature request is for @angular/core

Description

I have a scenario in my framework that I should find ComponentType by it’s name and then create it. In Angular 8 I used ComponentFactoryResolver["_factories"] to find component. (Component added to EntryComponent)

But in Ivy there is no _factories in ComponentFactoryResolver.

I tried to use _r3Injector.injectorDefTypes and then ["ɵmod"].declarations for each module. It was OK in development but in production mode declarations is always empty.

After that I tried to use directiveRegistry of TView . But I understood that only components stay on directiveRegistry that used.

Describe the solution you’d like

I think it would be nice if there is a service that metadata of modules and components can be accessible via it.

Describe alternatives you’ve considered

An alternative can be provide a service to register these types and then use them.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:21
  • Comments:29 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
priyanka01debcommented, May 18, 2021

Can we get a solution for this in Angular Ivy? It’s a much required feature I feel.

4reactions
tarangkhandelwalcommented, Jan 2, 2021

We are using a way to have dynamic components by extending modules to provide components that should be available via selectors. Hope this helps.

https://indepth.dev/posts/1400/components-by-selector-name-angular

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get component name from service in Angular without ...
How to get component name from service in Angular without using private API like view container ref · 1. constructor.name is not giving...
Read more >
Rendering dynamic components by selector name in Ivy
Angular gives us the mechanism to render components dynamically through View Container using ComponentFactory. To do this, we need to know ...
Read more >
Solved: Getting the component name in code
Solved: We're trying to address a bunch of accessibility issues, one in particular is proving quite difficult. We need to supply for=""
Read more >
How to get the class (component's) name in angular. - Medium
Recently i've encountered a problem where i wanted to have a list of different reusable “dynamic” components nested in a wrapper component ......
Read more >
Angular components overview
Run the ng generate component <component-name> command, where <component-name> is the name of your new component. By default, this command creates the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found