I'm developing a simple web application using angularJS and I'm running into this issue I cannot resolve. Running my website I get this error in console:
Uncaught Error: [$injector:modulerr] Failed to instantiate module App due to: Error: [$injector:nomod] Module 'App' 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.
But I'm sure I didn't misspell the module name or forgot to load it. Here's my code:
var App = angular.module('App', ['ngRoute', 'ngMaterial', 'ui-notification', 'ngFileUpload']);
App.run(['$rootScope', '$location', function($rootScope, $location) {
console.log("TEST");
}]);
App.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
// TODO: routing
}]);
App.factory('file-uploader', ['Upload', function(Upload) {
var uploadFile = function(file, callback) {
var uploader;
uploader = Upload.upload({
url: 'SERVER URL' + '/upload-file',
data: {
image: file
}
});
uploader.then(function(fileData) {
return callback(null, fileData);
});
uploader.catch(function(error) {
return callback(error, null);
});
};
return uploadFile;
}]);
This is my index.html:
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<meta name="description" content="">
<meta name="author" content="AUTHOR">
<title>PROJECT NAME | Login</title>
<link rel="stylesheet" href="/bower_ponents/angular-material/angular-material.css">
<link rel="stylesheet" href="/bower_ponents/angular-ui-notification/dist/angular-ui-notification.min.css">
<link rel="stylesheet" href="css/main.css" type="text/css">
</head>
<body ng-class="location" ng-cloak>
<div ng-view></div>
<script defer src="/bower_ponents/angular/angular.js"></script>
<script defer src="/bower_ponents/angular-route/angular-route.js"></script>
<script defer src="/bower_ponents/angular-aria/angular-aria.js"></script>
<script defer src="/bower_ponents/angular-animate/angular-animate.js"></script>
<script defer src="/bower_ponents/angular-messages/angular-messages.js"></script>
<script defer src="/bower_ponents/angular-ui-notification/dist/angular-ui-notification.min.js"></script>
<script defer src="/bower_ponents/angular-material/angular-material.js"></script>
<script defer src="/bower_ponents/jquery/dist/jquery.js"></script>
</body>
</html>
And I've installed all the packages with bower...
Can someone please tell me where is the problem and how can I solve it?
I'm developing a simple web application using angularJS and I'm running into this issue I cannot resolve. Running my website I get this error in console:
Uncaught Error: [$injector:modulerr] Failed to instantiate module App due to: Error: [$injector:nomod] Module 'App' 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.
But I'm sure I didn't misspell the module name or forgot to load it. Here's my code:
var App = angular.module('App', ['ngRoute', 'ngMaterial', 'ui-notification', 'ngFileUpload']);
App.run(['$rootScope', '$location', function($rootScope, $location) {
console.log("TEST");
}]);
App.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
// TODO: routing
}]);
App.factory('file-uploader', ['Upload', function(Upload) {
var uploadFile = function(file, callback) {
var uploader;
uploader = Upload.upload({
url: 'SERVER URL' + '/upload-file',
data: {
image: file
}
});
uploader.then(function(fileData) {
return callback(null, fileData);
});
uploader.catch(function(error) {
return callback(error, null);
});
};
return uploadFile;
}]);
This is my index.html:
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<meta name="description" content="">
<meta name="author" content="AUTHOR">
<title>PROJECT NAME | Login</title>
<link rel="stylesheet" href="/bower_ponents/angular-material/angular-material.css">
<link rel="stylesheet" href="/bower_ponents/angular-ui-notification/dist/angular-ui-notification.min.css">
<link rel="stylesheet" href="css/main.css" type="text/css">
</head>
<body ng-class="location" ng-cloak>
<div ng-view></div>
<script defer src="/bower_ponents/angular/angular.js"></script>
<script defer src="/bower_ponents/angular-route/angular-route.js"></script>
<script defer src="/bower_ponents/angular-aria/angular-aria.js"></script>
<script defer src="/bower_ponents/angular-animate/angular-animate.js"></script>
<script defer src="/bower_ponents/angular-messages/angular-messages.js"></script>
<script defer src="/bower_ponents/angular-ui-notification/dist/angular-ui-notification.min.js"></script>
<script defer src="/bower_ponents/angular-material/angular-material.js"></script>
<script defer src="/bower_ponents/jquery/dist/jquery.js"></script>
</body>
</html>
And I've installed all the packages with bower...
Can someone please tell me where is the problem and how can I solve it?
Share Improve this question edited Sep 26, 2018 at 6:06 jww 102k103 gold badges443 silver badges944 bronze badges asked May 31, 2016 at 7:52 Leonardo MinatiLeonardo Minati 3601 gold badge4 silver badges17 bronze badges 8-
6
Have you included the app somewhere in your html with
ng-app="App"
? – thepio Commented May 31, 2016 at 7:54 - This checklist may help: stackoverflow./a/26797874/930170 – S Panfilov Commented May 31, 2016 at 7:54
- @thepio sure, in my html i have html(ng-app="App") – Leonardo Minati Commented May 31, 2016 at 8:04
-
1
Have you also made sure you have all the external resources available? Like
ngRoute
etc? I got your code to work fine in jsfiddle: jsfiddle/gxn9x9g4 . I of course removed all the other depencies exceptngRoute
. – thepio Commented May 31, 2016 at 8:15 - Your <script> line for angular itself is the first one you include? – rrd Commented May 31, 2016 at 9:39
1 Answer
Reset to default 4It looks like you've forgotten to add your own script, based on the HTML you provided. I only see bower_ponents
stuff being included