简体   繁体   中英

Uncaught Error: [$injector:modulerr] using Angular JS and highcharts-ng

I am having a problem with implementing Highcharts in my Angular/Node/Express app. Using the highcharts-ng directive https://github.com/pablojim/highcharts-ng

I keep getting the following error in my console:

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

I have this in the head of my 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>

My template file:

<div class="container">

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

</div>

My Angular JS config:

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

        });
})

Can anyone help me what this error is about?

I presume that you have installed the highcharts-ng.js from the Node and it seems you have not included the same in your <script> block. You can find it under your node_modules directory.

Also as Steve Pitis pointed out, You need move your <script src="https://code.highcharts.com/highcharts.js"></script> before your app.js script inclusion.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM