core: ng-packagr with npm pack gives a Error: No provider for TranslateService!
I’m submitting a … (check one with “x”)
[ x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request
Current behavior I developed a library with the ng-packagr I use npm pack to package the library in a tarball and then I install it in another client app. The idea is that in my library I use ngx-translate but its in the client app where I provide the translations and the configuration of ngx-translate. The problem is that after doing and npm pack and installing the library I have a Error: No provider for TranslateService!
Expected/desired behavior To be able to translate in the library by configuring and providing translations in the client of the library.
Reproduction of the problem I have created a repo to demostrate what I’m talking about.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 39
Hi Ovidio,
I really should read the official angular.io docs first. It works now with forRoot() in your shared module which injects your service there. Also you dont need to provide it TranslateService in your parent app since the providers in class export take care of it.
So now it looks like this.
footer.module.ts
app.module.ts
For the angular.io docs, which maybe helps: https://angular.io/guide/ngmodule#why-userservice-isnt-shared https://angular.io/guide/ngmodule-faq#q-why-bad and onwards
https://github.com/dherges/ng-packagr/issues/259 solved the issue for me
Hi Ovidio,
Im still trying to put it on the right way now. Im on the same ship. Ill give you an update if I got it right