Angular Primeng: ERROR ReferenceError: Chart is not defined at UIChart.initChart (chart.js:53)
Imported:
"../node_modules/chart.js/dist/Chart.js",
"../node_modules/chart.js/dist/Chart.bundle.js",
"../node_modules/chart.js/dist/Chart.min.js",
"../node_modules/chart.js/dist/Chart.bundle.min.js"
import { Chart } from 'chart.js';
import { ChartModule } from 'primeng/primeng';
From your question and code it is not very clear what are the steps you followed to achieve this. If you follow the Primeng documentation properly you can achieve this easily. Below is the step by step detail which I followed to run the chart.
I am using:
First of all install chart js.
Now add the chartjs in your angular.json file.
it is not necessary to use "../" in your script. If your node_module and angular.json file at the same level then use like below and this is the default behavior :
In app.module.ts
Import only ChartModule do not import from Chart.js as you mentioned in your question.
Now in you component.html :
component.ts:
That's all we need to do.