Ionic + Angular Charts: Uncaught Error: Chart.js library needs to included

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

I am trying to include charts into my Ionic application, but I get error. I have download the angular.js folder and chart.js folder into my lib folder and added the following lines to index.html:

<script src="lib/angular-chart.js/dist/angular-chart.js"></script> <script src="lib/chart.js/dist/Chart.js"></script> <script src="lib/angular-chart.js/dist/angular-chart.min.js"></script> <script src="lib/chart.js/dist/Chart.min.js"></script> 

I also added chart.js to my module: angular.module('myApp', ['ionic', 'chart.js']) but I still get the error: Uncaught Error: Chart.js library needs to included

What am I doing wrong, how can I use chart.js in my app?

回答1:

The fix was to put before angular-chart.js as Jossef Harush implied as a comment in my post. Also it is redundant to import both ”min” and normal js files



回答2:

include js in this order

<script src="lib/chart.js/dist/Chart.min.js"></script>  <script src="lib/angular-chart.js/dist/angular-chart.min.js"></script> 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!