简体   繁体   中英

How to inject “Chart.js” in my module?

This is my Html. I have given paths like this

<html>
   <head>
      <script src="../../Content/Scripts/Script/angular.min.js"></script>
      <script src="../../Content/Scripts/Script/Chart.js"></script>
      <script src="../../Content/Scripts/Script/angular-charts.min.js"></script>
      <script src="../../Content/Scripts/Script/ui-bootstrap-tpls.js"> </script>
      <script src="../../Content/Scripts/Controllers/graphController.js"></script>  
   </head>
   <body>
       <div ng-app="app" ng-controller="financeAnalyticsController" class="support-section">
       {{a}}
       </div>
    </body>
</html>

In my script I wrote

var app = angular.module("app", [ "chart.js","ui.bootstrap", "ui.bootstrap.typeahead",]);

app.controller('financeAnalyticsController', function ($scope, $http, $filter) {
   $scope.a="testing";
});

When I am using in my application it is giving error

Uncaught Error: [$injector:modulerr]

How to solve this error?

I guess you are using a different version of angular-chart.js. Try using angularCharts instead of chart.js as the dependency module name, like so ...

var app = angular.module("app", ["angularCharts", "ui.bootstrap", "ui.bootstrap.typeahead"]);

app.controller('financeAnalyticsController', function($scope, $http, $filter) {
   $scope.a="testing";
});

or , use this version of angular-chart.js

see a working example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM