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
Angular dependency injection not working #15185
Comments
Some additional info: The project where this happens is a monorepo powered by Lerna (https://github.com/lerna/lerna#how-it-works). |
Can you reproduce this with e.g. a new hello-world component that does nothing but injecting the ChangeDetectorRef? |
Yes i still get the same issue. Here's the component: import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from '@angular/core';
@Component({
selector: 'nj-test-cdr',
templateUrl: './test-cdr.component.html',
styleUrls: ['./test-cdr.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TestCdrComponent {
constructor(private cdr: ChangeDetectorRef) {
}
} template: <p>test-cdr works!</p> its story: import {TestCdrComponent} from '@engie-group/fluid-design-system-angular';
import {Meta, moduleMetadata, Story} from '@storybook/angular';
export default {
title: 'TestCdr/Test Cdr',
component: TestCdrComponent,
decorators: [
moduleMetadata({
declarations: [TestCdrComponent],
}),
],
} as Meta;
export const TestCdr: Story = (args) => ({
template: `
<nj-test-cdr></nj-test-cdr>
`
}); Here's the browser preview with the same error: |
Any news about this issue ? I still have not found a fix yet |
Note: storybook version is 6.3.4 |
@ihor-panasiuk95 did you try to add ModalWindowService to providers as well ? |
@massi08 yes |
when I try to add the full chain of dependencies it works. But when I want to provide mock via { provide: ExclusiveFeatureModalService, useValue: {}} (like in unit-tests) the high-level service it doesn't work. |
There are no errors. The preview just doesn't display that story in the list. But the rest of stories that cover components without dependencies are displayed normally. |
My issue was solved. It wasn't related to DI actually. I created the feature request here: #15582 |
@kroeder any news on this I am still experiencing this issue on many of my components using ChangeDetectorRef |
We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:
|
Describe the bug
Angular dependency injection doesn't seem to work right with Angular 9.
To Reproduce
Simply import
ChangeDetectorRef
in component constructorComponent story:
Browser Error:
System
Environment Info:
Additional context
I've seen other closed tickets related to this issue (#7544), but the fix is to add "emitDecoratorMetadata": true in tsconfig.json.
This fix doesn't seem to work in my case.
The text was updated successfully, but these errors were encountered: