角度误差:[$ injector:modulerr]由于以下原因无法实例化模块angularCharts:错误:[$ injector:nomod]

时间:2015-02-04 11:26:36

标签: javascript angularjs angularjs-scope

这个问题已被多次询问,但在我的情况下,通常的答案没有用,所以发布它。我希望下面的代码后跟错误应该是自我解释的

错误:

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:     &#39;使用严格的&#39;;

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

2 个答案:

答案 0 :(得分:0)

有多个角度图表库可供使用。首先检查您正在使用哪一个,并在项目中添加该依赖项。 就像你正在使用

一样

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

charts.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>

答案 1 :(得分:-1)

您使用的是angular-chart.js吗?如果这样做,则依赖关系为chart.js,而不是angularCharts

检查angular-charts.js文件中的模块名称。检查依赖项名称。