为什么我不能渲染这个angularJS代码?

时间:2016-01-17 20:15:02

标签: javascript angularjs zingchart

此代码来自以下使用ZingChart的教程。 http://www.zingchart.com/blog/2015/03/05/zingchart-angularjs/

我的代码如下所示:

//my-zingchart.html
<html ng-app="myApp">
<head>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
   <script src="http://cdn.zingchart.com/zingchart.min.js">
   <script src="node_modules/zingchart-angularjs/src/zingchart-angularjs.js">
   <script>
       var app = angular.module('myApp',['zingchart-angularjs']);

        app.controller('MainController', function($scope){
        $scope.myData = [1,4,5,5,10];
});
   </script>
</head>
<body>
 <div ng-controller="MainController">
<zingchart id="chart-1" zc-values="myData"></zingchart>
</div>
 </body>
</html>

当我尝试在chrome中渲染时,我只得到一个空白页面,并出现以下错误:

  

未捕捉错误:[$ injector:modulerr] http://errors.angularjs.org/1.3.14/ $ injector / modulerr?p0 = myApp&amp; p1 =错误%3A%... gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.14%2Fangular.min的.js%3A17%3A381)

我已经找到了类似的错误,但他们的解决方案似乎无法解决我的问题。

1 个答案:

答案 0 :(得分:5)

关闭脚本代码!

<html ng-app="myApp">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script src="http://cdn.zingchart.com/zingchart.min.js"></script>
    <script src="node_modules/zingchart-angularjs/src/zingchart-angularjs.js"></script>
    <script>
        var app = angular.module('myApp', ['zingchart-angularjs']);

        app.controller('MainController', function ($scope) {
            $scope.myData = [1, 4, 5, 5, 10];
        });
    </script>
</head>
<body>
    <div ng-controller="MainController">
        <zingchart id="chart-1" zc-values="myData"></zingchart>
    </div>
</body>
</html>

结果

Now working