troyanskiy / ngx-resource

Resource (REST) Client for Angular 2
http://troyanskiy.github.io/ngx-resource/
200 stars 46 forks source link

Promise rejected for resource declared in custom ngModule #159

Closed adrianmarinica closed 5 years ago

adrianmarinica commented 5 years ago

After integrating the library and creating all the resources in the main AppModule, I decided to create a separate NgModule specifically for the resources. When doing so, all requests error out with Error: ResourceHandler is not provided at ResourceHandlerNoop.handle.

The resource handler is in fact provided in all resources through the constructor, even though it recently became an optional parameter.

I tried putting the imports: [ResourceModule.forRoot()] in both the AppModule and the custom module, both times the promise got rejected. I also looked over the forChild method, but it seems identical to the forRoot one. I guess it's provided for backwards compatibility?

Have I stumbled upon a bug, or am I not using things properly?

troyanskiy commented 5 years ago

Hello,

You have to import ResourceModule from @ngx-resourse/handler-ngx-http

сб, 24 авг. 2019 г. в 23:02, Adrian Marinica notifications@github.com:

After integrating the library and creating all the resources in the main AppModule, I decided to create a separate NgModule specifically for the resources. When doing so, all requests error out with Error: ResourceHandler is not provided at ResourceHandlerNoop.handle.

The resource handler is in fact provided in all resources through the constructor, even though it recently became an optional parameter.

I tried putting the imports: [ResourceModule.forRoot()] in both the AppModule and the custom module, both times the promise got rejected.

Have I stumbled upon a bug, or am I not using things properly?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/troyanskiy/ngx-resource/issues/159?email_source=notifications&email_token=AALXWLXVUXDVXVUK53YWBXLQGGOWPA5CNFSM4IPHHAY2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHGNATQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AALXWLWHDQF67OFB6NCVEUTQGGOWPANCNFSM4IPHHAYQ .

adrianmarinica commented 5 years ago

Thank you, it worked. Cheers!