AngularJS无法实例化zingchart模块

时间:2017-06-10 17:34:25

标签: javascript angularjs dependency-injection mean.io

我正在使用mean.io堆栈构建一个Web应用程序。我正在尝试添加'zingchart-angularjs'依赖项,我收到此错误:

[$injector:nomod] Module 'zingchart-angularjs' 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.

我是角色的新手,所以我很困惑,为什么我可以让'ngMaterial'依赖工作得很好但不是zingchart依赖。

有人能指出我正确的方向/描述我做错了吗?

这是我的js文件 - dashboard.js

(function() {
'use strict';

/* jshint -W098 */

function DashboardController($scope, Global, Dashboard, $stateParams) {
    $scope.global = Global;
    $scope.package = {
        name: 'dashboard'
    };
}

angular
    .module('mean.dashboard', ['ngMaterial', 'zingchart-angularjs'])
    .controller('DashboardController', DashboardController);

DashboardController.$inject = ['$scope', 'Global', 'Dashboard', '$stateParams'];

})();

的index.html

    <!DOCTYPE html>

<head>
  <script type="text/javascript" src="angular.min.js"></script>
  <script type="text/javascript" src="angular-animate.js"></script>
  <script type="text/javascript" src="angular-aria.js"></script>
  <script type="text/javascript" src="angular-material.js"></script>
  <script type="text/javascript" src="zingchart.min.js"></script>
  <script type="text/javascript" src="zingchart-angularjs.js"></script>
  <script type="text/javascript" src="dashboard.js"></script>
</head>


<body ng-app="mean.dashboard" layout="row" ng-cloak>

  <div class="container" layout="row" flex>
    <md-sidenav layout="column" class="md-whiteframe-10dp" md-is-locked-open='true'>
      <md-list>
        <md-list-item>
          <md-button>
            Dashboard
          </md-button>
        </md-list-item>
      </md-list>
    </md-sidenav>
    <md-content id="content" flex>
      <ng-view>
        <zingchart id="myChart" zc-json="myJson" zc-height=500 zc-width=600></zingchart>
      </ng-view>
    </md-content>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

index.html中,您需要在zingchart-angularjs之前加入script dashboard.js;

此外,我在angular-material scripts中看不到index.html ngMaterial

我将此添加到index.html并且效果很好:

<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="angular-animate.js"></script>
<script type="text/javascript" src="angular-aria.js"></script>
<script type="text/javascript" src="angular-material.js"></script>
<script type="text/javascript" src="zingchart.min.js"></script>
<script type="text/javascript" src="zingchart-angularjs.js"></script>
<script type="text/javascript" src="dashboard.js"></script>  

https://github.com/angular/material