-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No providers for Angular's services (ChangeDetectorRef, Renderer, ElementRef) in Angular. #7544
Comments
Can confirm this |
doing it like that works though - weird constructor(@Inject(ChangeDetectorRef) private cdr: ChangeDetectorRef) {} This might be caused by this: https://github.com/storybookjs/storybook/blob/next/app/angular/src/client/preview/angular/components/app.component.ts#L51 I've never used |
In this case you don't get errors but |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
So sad... |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
As I can see, not only |
yeah any service i add in the constructor throws: any way around this? |
I'm having the same issue when I try to inject an ElementRef and Renderer2 into a directive's constructor. Based on the implementation, I can see why ElementRef especially would be difficult to inject, but it's also a really important part of Angular. Not sure where to go from here... I'm 40 stories/components in and just now finding out I can't write directives! Edit: if it helps anyone, I was able to get around this issue using |
The solution to this is adding |
Hi: I'm having the same issue, just like @danielhdz56, my story works just fine but as soon as I add a service to my component it breaks with the error: Can't resolve all parameters for LoginComponent: (?, ?, ?). I added "emitDecoratorMetadata": true, to .storybook/tsconfig.json and now I get the error: NullInjectorError: No provider for Router! So I added a provider: .addDecorator( Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?, ?). @storybook/angular v5.3.9 in angular: @angular-devkit/architect 0.900.0-rc.10 |
@rootdevelopper You probably need to add the angular routing module to your decorator imports |
thanks, @patrickjm, I tried that already, I forgot to mention. |
I've created a PR (#9701) that should fix this issue. It will add |
Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.4 containing PR #9701 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.11 containing PR #9701 that references this issue. Upgrade today to try it out! |
Describe the bug
I try to create story for component which has a
ChangeDetecorRef
as dependency. As result I got an errorCan't resolve all parameters for MyComponentName: (?).
. If removeChangeDetectorRef
, all works well.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Story works well.
Screenshots
System:
The text was updated successfully, but these errors were encountered: