1

Trying to integrate chart.js with AngularJSbut this error is showing:

Error: $injector:modulerr Module Error. Failed to instantiate module chart.js

I know the is error is to do with where the link is declared in your header, but I have followed instructions from Angular Chart but to no avail. Any idea why this error is being thrown?

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-charts/0.2.7/angular-charts.min.js"></script>
<script src="scripts/app.js"></script>

var app = angular.module('myApp', ['ngRoute', 'angularMoment', 'ui.router', 'chart.js']);

1 Answer 1

2

Name of the chart module is angularCharts. so inject it instead of the chart.js

var app = angular.module('myApp', ['ngRoute', 'angularMoment', 'ui.router', 'angularCharts']);
Sign up to request clarification or add additional context in comments.

3 Comments

Well.... that was it. How come on the website it tells you to add chart.js as a dependency?
actually not sure why is that. i just look up the module and saw the name :D
Pffft, I been typing it in the last hour or so and they all say inject chart.js. God knows. Thanks for the help, I'll accept your answer asap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.