alpha-38: Need @Inject to inject ElementRef and DynamicComponentLoader
See original GitHub issueDI works fine in alpha-37, now it needs @Inject
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (14 by maintainers)
Top Results From Across the Web
Dynamic component loader - Angular
An application might need to load new components at runtime. This cookbook shows you how to add components dynamically. See the live example...
Read more >Angular 2 dynamic component injection and access to ...
I want to inject the dynamic components inside the datalist and be able to access the attribute suggestion search.result.component afterwards ...
Read more >Loading Components Dynamically in an Angular App
A tutorial that shows how to create an Angular app with dynamic component loading.
Read more >Loading Components Dynamically in Angular - SyntaxSuccess
In the following article I will show how to use ComponentFactoryResolver in Angular to insert components dynamically into the DOM.
Read more >Loading Components Dynamically in Angular 9 with Ivy
This is not exactly new and exclusive to Angular 9, but now we can have components without a module, and by making them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I started debugging your issue and found that
MyApp
gets transpiled to:Which means that the generated metadata for the param types is wrong. However, if you use
@Inject
instead ofObject
you getangular2_1.ElementRef
, which is correct.Same error occurs when I try to inject
DynamicComponentLoader
.Another thing I noticed: when using angular2-seed with gulp task with the following src, I get the error. However, if I use target
../app/*.ts
instead everything works.Another way to make it work is by changing the name of the export inside the angular2 bundle:
and later import it as:
PS: I dug inside the TypeScript compiler and saw that during the parameters serialization when writing metadata the
ElementRef
class is not being properly resolved; instead ofTypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
it is being resolved asTypeReferenceSerializationKind.ObjectType
, so may be a TypeScript issue?This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.