角度错误: [$injector:模块rr] 由于以下原因无法实例化模块角度图表: 错误: [$injector:nom

Angular Error: [$injector:modulerr] Failed to instantiate module angularCharts due to: Error: [$injector:nomod]

本文关键字:injector 模块 错误 实例化 nom rr      更新时间:2023-09-26

这个问题已经被问了很多次,但就我而言,通常的答案没有帮助,所以发布它。我希望下面的代码后跟错误应该是不言自明

错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module yoangfull2App due to:
Error: [$injector:modulerr] Failed to instantiate module angularCharts due to:
Error: [$injector:nomod] Module 'angularCharts' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

.HTML:

<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/json3/lib/json3.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/lodash/dist/lodash.compat.js"></script>
<script src="bower_components/angular-socket-io/socket.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/angular-charts/dist/angular-charts.js"></script>

Javascript: "使用严格";

angular.module('yoangfull2App', ['angularCharts'])
  .config(function ($routeProvider) {
    $routeProvider
      .when('/archives', {
        templateUrl: 'app/archives/archives.html',
        controller: 'ArchivesCtrl'
      });
  });

有多个角度图库可用。 首先检查您正在使用哪一个,然后将该依赖项添加到您的项目中。就像你正在使用一样

http://jtblin.github.io/angular-chart.js/

图表.js是依赖项名称,或者如果您正在使用

http://chinmaymk.github.io/angular-charts/

您使用 Bower 安装它,然后按照与那里建议的相同顺序添加它:

<script type='text/javascript' src='./bower_components/angular/angular.min.js'></script> 
<script type='text/javascript' src='./bower_components/d3/d3.min.js'></script> 
<script type='text/javascript' src='./bower_components/angular-charts/dist/angular-charts.min.js'></script>

你使用的是角度图.js吗?如果这样做,则依赖项是 chart.js ,而不是angularCharts

检查角度图.js文件中的模块名称。 检查依赖项名称。