1
    I saw a similiar problem but it was not with ng2-charts. I already spent more the 1 
    day on what I believe is an environment issue. I need help big time.


    Crash Message:
    Error: NG0203: inject() must be called from an injection context (a constructor, a 
    factory function or a field initializer). Find more at 
    https://angular.io/errors/NG0203
at injectInjectorOnly (core.mjs:4751:15)
at Module.ɵɵinject (core.mjs:4762:12)
at Object.NgChartsModule_Factory [as useFactory] (ng2-charts.mjs:274:1)
at Object.factory (core.mjs:9324:38)
at R3Injector.hydrate (core.mjs:9237:35)
at R3Injector.get (core.mjs:9131:33)
at injectInjectorOnly (core.mjs:4757:33)
at ɵɵinject (core.mjs:4761:12)
at useValue (core.mjs:8897:65)
at R3Injector.resolveInjectorInitializers (core.mjs:9174:17)

index.js:551 [webpack-dev-server] Live Reloading enabled.

Code added to app-module.ts:

import { NgChartsModule }                        from 'ng2-charts';

@NgModule({  NgChartsModule, .......



Package.json
"dependencies": {
"@angular/animations": "14.1.0",
"@angular/common": "14.1.0",
"@angular/compiler": "14.1.0",
"@angular/core": "14.1.0",
"@angular/forms": "14.1.0",
"@angular/material": "14.1.0",
"@angular/material-moment-adapter": "14.1.0",
"material-design-icons": "3.0.1",
"@angular/platform-browser": "14.1.0",
"@angular/platform-browser-dynamic": "14.1.0",
"@angular/router": "14.1.0",
"@types/file-saver": "^2.0.5",
"core-js": "3.24.0",
"chart.js": "3.8.2",
"ng2-charts": "4.0.0",
"rxjs": "7.5.6",
"rxjs-compat": "6.6.7",
"tslib": "2.4.0",
"zone.js": "0.11.7",

Installation: npm install --g @angular/cli@14.1.0 npm i --unsafe-perm --verbose npm i @types/chart.js

Guy Gallant
  • 183
  • 1
  • 3
  • 11

0 Answers0