I get only this error text in Chrome. No any additional info:
What does it mean? What happened? Is there a way to tell Angular or Chrome to show more verbose error information?
Here is my app.js file. Nothing else is included:
'use strict';
// Declare app level module which depends on filters, and services
var vsApp = angular.module('vsApp', [
'ngRoute',
'vsApp.filters',
'vsApp.services',
'vsApp.directives',
'vsApp.controllers'
]);
vsApp.config(["$routeProvider"], function($routeProvider) {
$routeProvider.when('/registration', {templateUrl: 'partials/reg.html', controller: 'regCtrl'});
$routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'loginCtrl'});
$routeProvider.otherwise({redirectTo: '/'});
});
vsApp.controller("regCtrl", function() {});
vsApp.controller("loginCtrl", function() {});
ng-app attribute inclusion:
<!DOCTYPE html>
<html ng-app="vsApp">
My <head> tag:
<script id="angularScript" src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/assets/js/app.js"></script>
UPD:
Protractor brought more info:
Message:
UnknownError: unknown error: [$injector:modulerr] Failed to instantiate module vsApp due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
http://errors.angularjs.org/1.3.0-build.2795+sha.222d473/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string
at http://localhost:3000/bower_components/angular/angular.js:78:12
at assertArg (http://localhost:3000/bower_components/angular/angular.js:1583:11)
at assertArgFn (http://localhost:3000/bower_components/angular/angular.js:1593:3)
at annotate (http://localhost:3000/bower_components/angular/angular.js:3318:5)
at Object.invoke (http://localhost:3000/bower_components/angular/angular.js:3986:21)
at runInvokeQueue (http://localhost:3000/bower_components/angular/angular.js:3915:35)
at http://localhost:3000/bower_components/angular/angular.js:3924:11
at Array.forEach (native)
at forEach (http://localhost:3000/bower_components/angular/angular.js:320:11)
at loadModules (http://localhost:3000/bower_components/angular/angular.js:3905:5)
I don't know how to get more verbose error messages. I don't think it is even possible. However, you seem to have a at least a syntax error:
vsApp.config(["$routeProvider", function($routeProvider) {
/* notice the [ ] */
}]);
because you're using annotated injection of dependencies, just like in the documentation: https://docs.angularjs.org/guide/providers#providers_provider-recipe
myApp.config(["unicornLauncherProvider", function(unicornLauncherProvider) {
unicornLauncherProvider.useTinfoilShielding(true);
}]);
In any case I tried to reproduce the error message you got but I only obtain useful error messages. see http://jsfiddle.net/CE6j9/1/
Uncaught Error: [$injector:modulerr] Failed to instantiate module vsApp due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
http://errors.angularjs.org/1.2.1/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string
at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:78:12
at assertArg (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:1346:11)
at assertArgFn (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:1356:3)
at annotate (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:2926:5)
at Object.invoke (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3587:21)
at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3534:37
at Array.forEach (native)
at forEach (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:300:11)
at loadModules (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3521:5)
at createInjector (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3461:11)
http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=vsApp&p1=Error%3A%2…cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.2.1%2Fangular.js%3A3461%3A11)
http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=vsApp&p1=Error%3A%2…cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.2.1%2Fangular.js%3A3461%3A11) angular.js:78
(anonymous function) angular.js:78
(anonymous function) angular.js:3555
forEach angular.js:300
loadModules angular.js:3521
createInjector angular.js:3461
doBootstrap angular.js:1282
bootstrap angular.js:1297
angularInit angular.js:1246
(anonymous function) angular.js:20126
trigger angular.js:2298
(anonymous function) angular.js:2562
forEach angular.js:300
eventHandler
maybe you had something else interfering?
I got the lower half of errors (with line numberS) when I clicked in the arrow. maybe you have the wrong settings in chrome?
Related
I use Angularjs 1.2.21 in my project.
I download and install angular-route.min.js file
Here is main module defenition:
angular.module('dashboard', ['ngRoute','layers'])
.config(function () {});
In console I get this 2 errors:
Uncaught TypeError: Cannot read property 'w' of null
at initialize.setMap (OpenLayers.js:625)
at initialize.addLayer (OpenLayers.js:182)
at initialize.addLayers (OpenLayers.js:182)
at initialize (OpenLayers.js:177)
at mapApp.js:205
at HTMLDocument.<anonymous> (mapApp.js:221)
at fire (jquery-1.8.3.js:974)
at Object.fireWith [as resolveWith] (jquery-1.8.3.js:1084)
at Function.ready (jquery-1.8.3.js:406)
at HTMLDocument.DOMContentLoaded (jquery-1.8.3.js:83)
And second error is this:
angular.min.js:92 TypeError: Cannot read property 'charAt' of undefined
at Tb.$$parse (angular.min.js:86)
at angular.min.js:90
at k.$eval (angular.min.js:111)
at k.$digest (angular.min.js:108)
at angular.min.js:90
at angular.min.js:38
at q (angular.min.js:7)
at g (angular.min.js:38)
at angular.min.js:31
at q (angular.min.js:7)
When I remove ngRoute from dependency injection everything works fine:
angular.module('dashboard', ['layers'])
.config(function () {});
Any idea why I get errors above?
I have this piece of code written and for some reason after I made some changed it complains within data obj css property.
The error says that the concat is not defined, even thou I have it on my packages.json defined.
.state('signup-facebook', {
url: '/students/signup',
templateUrl: MODULE_PATH + 'become/authentication/signup/connect-facebook.client.view.html',
controller: 'StudentAuthenticationController',
controllerAs: 'StudentAuthentication',
data: {
step: 1,
animate: true,
css: cssModules.students.concat(cssModules.users), // This line of code showing error
cssModuleName: 'students'
}
})
I just dont understand why this is not working.
Here you have the full error that Chrome displays:
Uncaught Error: [$injector:modulerr] Failed to instantiate module
coderstrust due to: Error: [$injector:modulerr] Failed to instantiate
module students due to: TypeError: Cannot read property 'concat' of
undefined
at config (http://localhost:3000/modules/students/client/config/students.become.client.routes.js:23:45)
at Object.invoke (http://localhost:3000/lib/angular/angular.js:4708:19)
at runInvokeQueue (http://localhost:3000/lib/angular/angular.js:4601:35)
at http://localhost:3000/lib/angular/angular.js:4610:11
at forEach (http://localhost:3000/lib/angular/angular.js:322:20)
at loadModules (http://localhost:3000/lib/angular/angular.js:4591:5).....
What is cssModules.students? The problem is not with concat. The problem is with cssModules.students which is undefined and when you will try to perform any method on undefined you will get an error.
Hope this helps :)
Happy Learning
I'm following a tutorial which is making Angular on Rails.
here is a JSFiddle URL for the project: https://jsfiddle.net/dcbavw4e/4/
I'm currently getting 2 errors right now:
1. Uncaught SyntaxError: Unexpected token .
Error occuring at : .controller('MainCtrl', ['$scope', 'posts', function($scope, posts) {
2. angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module flapperNews due to:
Error: [$injector:nomod] Module 'flapperNews' 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.4.9/$injector/nomod?p0=flapperNews
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:68:12
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:2006:17
at ensure (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:1930:38)
at module (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:2004:14)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:4447:22
at forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:341:20)
at loadModules (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:4431:5)
at createInjector (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:4356:11)
at doBootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:1677:20)
at bootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js:1698:12)
http://errors.angularjs.org/1.4.9/$injector/modulerr?p0=flapperNews&p1=Erro….googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.9%2Fangular.js%3A1698%3A12)
I'm not really sure what I'm doing wrong since I did check App name in index.html and app.js but they all match.
There were some syntax errors in your code. At line 24 on the fiddle, you used a ';' it breaks the chain, so controller 'MainCtrl' won't get attached to module 'flapperNews'. (There are a few more mistakes as well.) See the fiddle in comments
.factory('posts', [function(){
var o = {
posts: []
};
return o;
}]);
I written the code as my angular controller as below:
.config(function($routeProvider, $locationProvider, $httpProvider) ,
But I always get this error:
angular.js:9193 Error: [$injector:unpr] Unknown provider: locationProvider <- location <- activeNavDirectivehttp://errors.angularjs.org/1.2.3/$injector/unpr?p0=locationProvider%20%3C-%20location%20%3C-%20activeNavDirective at
/js/bower_components/angular/angular.js:78:12 at
/js/bower_components/angular/angular.js:3473:19 at Object.getService [as get]
/js/bower_components/angular/angular.js:3600:39) at
/js/bower_components/angular/angular.js:3478:45 at getService
/js/bower_components/angular/angular.js:3600:39) at Object.invoke
/js/bower_components/angular/angular.js:3622:13) at
/js/bower_components/angular/angular.js:5146:43 at Array.forEach (native) at forEach
/js/bower_components/angular/angular.js:300:11) at Object.<anonymous>
(xxxxx/js/bower_components/angular/angular.js:5144:13)angular.js:9193 (anonymous function)
It seems somewhere you are using $locationProvider without the $ prefix locationProvider. Can you check.
I'm trying to set up a unit testing environment for my project and I'm having some problems. I'm trying to use Testacular with Jasmine for testing my AngularJS code.
I have a module Services which has a factory method called KeepAlive. Here is its set up.
angular.module('services', []).factory('KeepAlive', ['$rootScope', function($rootScope){
//My Code
}]);
This module is attached to a module called MainModule. Here is its code.
angular.module('MainModule', ['filters', 'services', 'directives', 'ui'])
.config(['$httpProvider', function($httpProvider){
//My Code
}]).run(['$rootScope', '$timeout', '$routeParams', 'KeepAlive', function($rootScope, $timeout, $routeParams, KeepAlive){
//My Code
}]);
So Now I want to add this code for my tests. So here is my testacular file set up.
JASMINE,
JASMINE_ADAPTER,
'assets/lib/jquery/jquery-1.7.1.js',
'assets/lib/angular/angular.js',
'assets/lib/angular/angular-ui.js',
'jsTests/MockingLib/angular-mocks.js',
'assets/scripts/modules/Admin.js',
'assets/scripts/modules/MainModule.js',
'assets/scripts/services/KeepAlive.js',
'assets/scripts/services/Admin.js',
'assets/scripts/filters.js',
'assets/scripts/directives.js',
'assets/scripts/controllers/admin/*.js',
Now this is throwing a error in my testacular console. Here is the error that I'm getting.
Error: Unknown provider: KeepAliveProvider <- KeepAlive
at Error (<anonymous>)
at d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2627:8
at Object.getService [as get] (d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2755:32)
at d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2632:38
at getService (d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2755:32)
at Object.invoke (d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2773:6)
at d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2637:71
at Array.forEach (native)
at forEach (d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:110:11)
at Object.createInjector [as injector] (d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2637:3)
Here is my Jasmine Test case.
beforeEach(function () {
admin = module("MainModule");
module("services");
});
What I'm I missing? I'm new to testacular. Thanks in advance.
The error says that somebody asked for a service called "KeepAlive" but the injector does not know how to create it (there is no provider for it).
That means, you probably didn't load the module.
When you bootstrap your app on production, you give it ng-app="something", which tells Angular which module to load. In the same way, you need to specify which modules you wanna load during testing.
This should solve your problem:
beforeEach(module('services'));