-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 5 - StaticInjectorError[ActionsSubject]: Function/Class not supported #549
Comments
As listed on Angular 5 changelog
Reply if this change fixes it. |
hello
I'm not using platform providers how can I debug this error? where to look? 😕 the only non-standard implementation is abstract CanLoad guard that injects Store in constructor:
|
@voznik why you don't set Store as a constructor parameter and use Injector? There was something about decorators and dynamic functions when I tried to run unit:tests with Angular5 against ngrx monorepo, (basicly dependency hell ensued, codelyzer, zonejs, rxjs, typescript had to be upgraded thus breaking tests since jasmine had to be upgraded....) and then run out of time to use for that. Try this if you just need to get it working. import * as fromRoot from '../reducers';
export class BookExistsGuard implements CanActivate {
constructor(
private store: Store<fromRoot.State>,
private service: BookService,
private router: Router
) { }
// ....
} |
OK I think I found the problem. in StoreModule providers you add ACTIONS_SUBJECT_PROVIDERS. But this provider is not following StaticProvider syntax. This should be:
Am I guessing right? |
If only I had time to look into #553 with Angular 5. |
In case this helps someone: I was experiencing a similar error on a project that was not using the Angular CLI. I believe the problem went away when I upgraded the version of TypeScript to 2.4.0, as is documented in the Angular 5 release notes. Edit: I'm no longer sure if this is what solved my issue. I am still having sporadic problems with this, which I now believe relates to case sensitivity of the import statement in the component where the service was injected. Usually I would match case sensitivity of the package structure / file name on disk, but for the second import from the directory the file must be in all lower case, or else it throws an error. This makes no logical sense to me, but for the moment it is solving my issue. |
In my experience, I had the same problem with a service, and I noted that I forgot to declare providers: [ ServiceName ] in the @component section of the ts file |
If you passing some custom class instance into component constructor it may produce the same problem. It is because of DI, rather you can declare a property in the component class. At least I had that problem. |
@lakhanpujeri instead of injecting your service in constructor ,use a property instead thanks @maksimbykov |
Hello All,
I Imported the following:
I added the store module in imports as : I have not seen this error when I add this and it works as expected as far as I can tell. Hope this helps! |
@straiforos Which file you are imported above things? |
It solves my problem but when i use property , returns undefined why? :| |
I'm submitting a...
What is the current behavior?
I am injecting StoreModule.forRoot(reducers, {metaReducers}).providers into platform providers.
After migration to angular 5, I have an error in the console:
StaticInjectorError[ActionsSubject]: Function/Class not supported
Expected behavior:
Application should start without error.
Minimal reproduction of the problem with instructions:
Version of affected browser(s),operating system(s), npm, node and ngrx:
@ngrx 4.1.0
@angular 5.0.0
Other information:
The text was updated successfully, but these errors were encountered: