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

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!

Related

how to solve jasmine error "Error during loading: Script error." when jquery used?

I test cordova project with jasmine and I add jquery and jasmine-jquery to jasmine test but jasmine show below code .
ReferenceError: selectLevel() is not defined
and Jasmine not worked and return Error during loading: Script error. when my app.js is
(function($) {
function selectLevel() {
level = 1;
}
})(jQuery);
but work when (function($) { removed
JasmineHTML FIle
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v3.5.0</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-3.5.0/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-3.5.0/jasmine.css">
<script src="lib/jasmine-3.5.0/jasmine.js"></script>
<script src="lib/jasmine-3.5.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-3.5.0/jasmine-jquery.js"></script>
<script type="text/javascript" src="lib/jasmine-3.5.0/jquery.js"></script>
<script src="lib/jasmine-3.5.0/boot.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="app.js"></script>
<!-- include spec files here... -->
<script src="spec/PlayerSpec.js"></script>
</head>
<body>
</body>
</html>
In this case, how do I solve this?

AngularJs Error: [$injector:modulerr] by ngRoute?

Probably a dupicate (Failed to instantiate module error in Angular js) but the given measures (including ng-route in HTML didn't solve the problem).
This is the error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module coursemate due to:
Error: [$injector:nomod] Module 'coursemate' 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.
this is my app.js
var coursemate = angular.module('coursemate', ["ngRoute"]);
coursemate.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "view1.html"
})
.otherwise({
redirectTo : '/'
});
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
this is my index.html
<!DOCTYPE html>
<html lang="de" ng-app="coursemate">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>CourseMate</title>
<base href="/CourseMate/" />
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="css/mdb.min.css" rel="stylesheet">
<!-- Your custom styles (optional) -->
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<ng-view>
</ng-view>
</body>
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="js/tether.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.min.js"></script>
<!-- AngularJS reditect -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.js"></script>-->
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script src="/app.js"></script>
</html>
I can not find my mistake as I don't think that I have initialized the app in a wrong way?
Remove the ";" after redirectTo: '/'. And make sure that you have all your reference in your CourseMate directory.

Angular app working on Firefox/IE but not chrome

I hosted my angular App on Amazon Web Services S3. It is working like a charm in Firefox and IE but not in Chrome. In console I keep receiving :
(index):1 Uncaught SyntaxError: Unexpected token <
(index):1 Uncaught SyntaxError: Unexpected token <
My index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Application</title>
<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Roboto:400,500,700,400italic'>
<link href="lib/angular-material/angular-material.min.css" rel="stylesheet">
<link href="css/style.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- js libs -->
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular-ui-router/release/angular-ui-router.min.js"></script>
<!-- angular material requirements -->
<script src="lib/angular-animate/angular-animate.min.js"></script>
<script src="lib/angular-aria/angular-aria.min.js"></script>
<script src="lib/angular-messages/angular-messages.min.js"></script>
<!-- angular material -->
<script src="lib/angular-material/angular-material.min.js"></script>
<!-- your app's js -->
<script src="modules/Add/add.js"></script>
<script src="js/all.min.js"></script>
</head>
<body ng-app="Application">
<div class="ng-main" ui-view ng-cloak></div>
</body>
</html>
CORS are activated! Do you have any idea? Any help would be appreciated!
PS : Locally, with npm start, it is also working on chrome without any problem!
All I had to do is CTRL+MAJ+R on Chrome and it is working like a charm! Solved

Unable to load ngRoute module

I'm working on a Node.js project that uses Angular, and I'm trying to implement multiple views and routing. I've followed the instructions outlined here for installing the angular-route.js file and dependent module:
https://docs.angularjs.org/api/ngRoute
But I still get this error in the console:
Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' 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.
http://errors.angularjs.org/1.3.20/$injector/nomod?p0=ngRoute
Here are the parts that seem relevant from my controller and HTML files:
app.js
var blogApp = angular.module('blogApp', ['ngRoute']);
index.html
<!DOCTYPE html>
<html ng-app="blogApp">
<head>
<title>Blog Posts</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- styles -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="stylesheets/style.css" rel="stylesheet" media="screen">
</head>
<body ng-controller="postController">
// page content
<!-- scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.js"></script>
<script src"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>
<script src="javascripts/app.js"></script>
</body>
</html>
I'm new to working with Angular and Node, so any thoughts on this greatly appreciated!
It's just a typo (missing equal sign). This line:
<script src"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
Should be:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
There is a very small typo in the script include for ngRoute. You had src"https:// rather than src="https://
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>
<script src="javascripts/app.js"></script>
You can debug these kinds of issues by checking the developer tools and making sure the script is loaded without error.

Uncaught TypeError: $(...).stellar is not a function

I am trying to implement the stellar plugin and far as I can see, I have included all the necessary js. However, in the dev tools console I keep getting the 'Uncaught TypeError: $(...).stellar is not a function'.
This is what I have in the head tags:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UFT-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>QE | Welcome</title>
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/stuff.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="js/jquery.stellar.js"></script>
<script src="js/scrip.js"></script>
<script src="js/jquery.nicescroll.js"></script>
And this is is the scrip.js file that the error is referring to:
$(document).ready(function() {
$(window).stellar();
});
$(document).ready(
function() {
$("html").niceScroll({
cursorcolor:"rgba(30,30,30,.5)",
zindex:999,
scrollspeed:100,
mousescrollstep:50,
cursorborder:"0px solid #fff",
});
});
Please help me
I have found out that the problem was with js/vendor/jquery.js which was I forgotten that had placed that at the bottom of the index.html file. When I removed it, the stellar function worked. Not sure why that affects stellar.js though.
Add javascript links to the Layout Page.
Remove script links from the inner page

Categories

Resources