ng-chartjs icon indicating copy to clipboard operation
ng-chartjs copied to clipboard

No provider for StoreService

Open ursedaniel opened this issue 4 years ago • 21 comments

I'm facing a problem, when running with --prod flag I get this error in console after following your example here @93Alliance : (https://github.com/93Alliance/ng-chartjs/issues/21) Screenshot 2020-10-18 at 17 49 21 Screenshot 2020-10-18 at 17 49 39 Screenshot 2020-10-18 at 17 49 58 Screenshot 2020-10-18 at 19 15 22

Any ideas how to fix it? without --prod flag it works pretty good but I need it to be prod valid, thanks! P.S. I've imported the module in a lazy loaded module, if I just import it in AppComponentModule it will not recognise the import.

ursedaniel avatar Oct 18 '20 14:10 ursedaniel

I can't reproduce your problem, could you provide me with a demo?

93Alliance avatar Oct 19 '20 00:10 93Alliance

Thanks for the response, the project is quite big I'm thinking of a way to showcase it to you... P.S. Did you tried with --prod? Maybe I don't have the package.json right versions....

ursedaniel avatar Oct 19 '20 09:10 ursedaniel

yes, it works very well

93Alliance avatar Oct 19 '20 09:10 93Alliance

You can try upgrade chart.js version to 2.9.3

"chart.js": "^2.9.3",

93Alliance avatar Oct 19 '20 09:10 93Alliance

Screenshot 2020-10-19 at 12 38 47 Screenshot 2020-10-19 at 12 38 54

Apparently importing the two services like this fixed the prod issue....

ursedaniel avatar Oct 19 '20 09:10 ursedaniel

What is your Angular version?

93Alliance avatar Oct 19 '20 09:10 93Alliance

@93Alliance I'm also having the same issue raised by @ursedaniel .

My angular version is 8.2.1

Also I've tried to add StoreService in providers. But at that time I'm getting another error

Module not found: Error: Can't resolve 'ng-chartjs/lib/store.service'

akhiljozph avatar Dec 21 '20 07:12 akhiljozph

What is your version of ng-chartjs?

93Alliance avatar Dec 21 '20 08:12 93Alliance

"ng-chartjs": "^0.2.1"

akhiljozph avatar Dec 21 '20 08:12 akhiljozph

I can use it normally in this demo https://stackblitz.com/edit/angular-8-ng-chartjs?file=src/app/app.component.ts

93Alliance avatar Dec 21 '20 08:12 93Alliance

I've changed the my code with code in the above demo. Still the " no provider for storeService" error exists in browser.

akhiljozph avatar Dec 21 '20 10:12 akhiljozph

Please provide me with your demo.

93Alliance avatar Dec 21 '20 10:12 93Alliance

The StoreService is private, you can't export the StoreService from ng-chartjs

93Alliance avatar Dec 21 '20 13:12 93Alliance

Then how can I use StoreService. Do I need to use the seperate folder as shown in git repo?

akhiljozph avatar Dec 22 '20 05:12 akhiljozph

Why do you use StoreService?

93Alliance avatar Dec 22 '20 05:12 93Alliance

I've implemented the ng-chartjs in a project that I'm working. When I'm running the project with --prod flag, I'm facing a problem as @ursedaniel mentioned in the issue. So, I just tried to import StoreService. If I can't import StoreService, then how will I solve the issue?

akhiljozph avatar Dec 22 '20 06:12 akhiljozph

Could you provide me with a demo?

93Alliance avatar Dec 22 '20 06:12 93Alliance

I can't share the project, but I will share a demo.

akhiljozph avatar Dec 22 '20 06:12 akhiljozph

ok

93Alliance avatar Dec 22 '20 06:12 93Alliance

I've implemented the ng-chartjs in a project that I'm working. When I'm running the project with --prod flag, I'm facing a problem as @ursedaniel mentioned in the issue. So, I just tried to import StoreService. If I can't import StoreService, then how will I solve the issue?

Do you enable ivy?

93Alliance avatar Dec 23 '20 00:12 93Alliance

Screenshot 2020-10-19 at 12 38 47 Screenshot 2020-10-19 at 12 38 54

Apparently importing the two services like this fixed the prod issue....

This solution really helped with angular 8 prod build.

arjunnemical avatar Nov 04 '21 16:11 arjunnemical