No providers for Angular's services (ChangeDetectorRef, Renderer, ElementRef) in Angular.
See original GitHub issueDescribe the bug
I try to create story for component which has a ChangeDetecorRef
as dependency. As result I got an error Can't resolve all parameters for MyComponentName: (?).
. If remove ChangeDetectorRef
, all works well.
To Reproduce Steps to reproduce the behavior:
- Create component with ChangeDetecorRef as dependency.
- Try to write story for the component.
Expected behavior Story works well.
Screenshots
System:
- OS: Windows10
- Device: Dell Latitude
- Browser: chrome
- Framework: angular@8
- Version: @storybook/angular": “^5.1.9”
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
angular - Trigger update of component view from service
ChangeDetectorRef is not option to use here. It is looking for changes in a given component and its children.
Read more >ChangeDetectorRef
Base class that provides change detection functionality. A change-detection tree collects all views that are to be checked for changes. Use the methods...
Read more >Using Renderer2 in Angular
Learn how to use methods from Angular's Renderer2 service to abstract ... constructor(private renderer: Renderer2, private el: ElementRef) ...
Read more >Make the most of Angular DI: private providers concept
Get some Angular entities like ChangeDetectorRef , ElementRef and other from DI. · Get a service to use it in a component. ·...
Read more >[Solved]-Angular 4: Mock ElementRef-angular.js
_providers array. And then we can say: hey, TestBed , give me this provider ElementRef : // ... let elRef: ElementRef; beforeEach(() =>...
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 FreeTop 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
Top GitHub Comments
The solution to this is adding
"emitDecoratorMetadata": true
to your .storybook/tsconfig.json.https://stackoverflow.com/a/57115788/2609014
This helped me, thanks. Just added to tsconfig.json the
I’m using 5.3.6, did not try the newer version @shilman mentioned above, but I’m guessing the PR #9701 solved that, cuz it does the same.