未捕获错误:[$ injector:modulerr]使用Angular JS和highcharts-ng

时间:2016-10-06 08:04:25

标签: javascript angularjs node.js highcharts highcharts-ng

我在Angular / Node / Express应用程序中实现Highcharts时遇到问题。使用highcharts-ng指令https://github.com/pablojim/highcharts-ng

我在控制台中一直收到以下错误:

  

angular.js:38未捕捉错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.8/ $ injector / modulerr?p0 = stocksApp& p1 =错误%... ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.8% 2Fangular.min.js%3A20%3A390)

我在index.html的头部有这个:

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>    
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.js"></script> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!--link custom CSS file -->
    <link rel="stylesheet" type="text/css" href="/css/style.css">
    <script src="/js/app.js"></script>
    <script src="https://code.highcharts.com/highcharts.js"></script>   
</head>

我的模板文件:

<div class="container">

    <highchart id="chart1" config="chartConfig"></highchart>

</div>

我的Angular JS配置:

angular.module("stocksApp", ['ngRoute', 'highcharts-ng'])
   .config(function($routeProvider){
    $routeProvider
        .when("/", {
           templateUrl: "stocks.html",
           controller: "mainController",

        });
})

任何人都可以帮我解决这个错误吗?

1 个答案:

答案 0 :(得分:2)

我认为您已经安装了highcharts-ng.js中的Node,但似乎您的<script>块中没有包含相同内容。您可以在node_modules目录下找到它。

同样正如Steve Pitis指出的那样,您需要在<script src="https://code.highcharts.com/highcharts.js"></script>脚本包含之前移动app.js

希望这有帮助!