AngularJS unit test pascalprecht.translate not available - angularjs

Uncaught Error: [$injector:nomod] Module 'pascalprecht.translate' 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.8/$injector/nomod?p0=pascalprecht.translate
(anonymous function)
(anonymous function)
ensure
module
angular.module
(anonymous function)
(anonymous function)
(anonymous function)
I have included in the index.html :
'../js/angular-translate/*.js',
and in app.module : angular.module('app name', [..,'pascalprecht.translate',])

Related

AngularJS $injector error on force refresh

I'm using AngularJS 1.6 with webpack.
When I force a refresh in Chrome (Shift+F5) my app fails to bootstrap and I get the following error:
app-a1677133c4.js:101030Uncaught TypeError: Cannot read property 'substr' of null
at app-a1677133c4.js:101030
at app-a1677133c4.js:101030
at Object.<anonymous> (app-a1677133c4.js:101030)
at Object.<anonymous> (app-a1677133c4.js:101031)
at __webpack_require__ (app-a1677133c4.js:20)
at app-a1677133c4.js:116
at Object.<anonymous> (app-a1677133c4.js:289)
at __webpack_require__ (app-a1677133c4.js:20)
at Object.<anonymous> (app-a1677133c4.js:47)
at __webpack_require__ (app-a1677133c4.js:20)
(anonymous) # app-a1677133c4.js:101030
(anonymous) # app-a1677133c4.js:101030
(anonymous) # app-a1677133c4.js:101030
(anonymous) # app-a1677133c4.js:101031
__webpack_require__ # app-a1677133c4.js:20
(anonymous) # app-a1677133c4.js:116
(anonymous) # app-a1677133c4.js:289
__webpack_require__ # app-a1677133c4.js:20
(anonymous) # app-a1677133c4.js:47
__webpack_require__ # app-a1677133c4.js:20
(anonymous) # app-a1677133c4.js:40
(anonymous) # app-a1677133c4.js:43
app-a1677133c4.js:11195 Uncaught Error: [$injector:modulerr] Failed to instantiate module scheduleApp due to:
Error: [$injector:nomod] Module 'scheduleApp' 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.6.1/$injector/nomod?p0=scheduleApp
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11195:13
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13310:18
at ensure (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13234:39)
at module (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13308:15)
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15863:23
at forEach (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11484:21)
at loadModules (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15847:6)
at createInjector (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15769:20)
at doBootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12965:21)
at bootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12986:13)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=scheduleApp&p1=Erro…host%3A5000%2Fstatic%2Fscheduling-angular%2Fapp-a1677133c4.js%3A12986%3A13)
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11195:13
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13310:18
at ensure (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13234:39)
at module (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:13308:15)
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15863:23
at forEach (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11484:21)
at loadModules (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15847:6)
at createInjector (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15769:20)
at doBootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12965:21)
at bootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12986:13)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=scheduleApp&p1=Erro…host%3A5000%2Fstatic%2Fscheduling-angular%2Fapp-a1677133c4.js%3A12986%3A13)
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11195:13
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15886:16
at forEach (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:11484:21)
at loadModules (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15847:6)
at createInjector (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:15769:20)
at doBootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12965:21)
at bootstrap (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12986:13)
at angularInit (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:12871:6)
at http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:44104:6
at HTMLDocument.trigger (http://localhost:5000/static/scheduling-angular/app-a1677133c4.js:14441:6)
The app is called "scheduleApp" - the module that fails to load and is referenced in the above error.
On a second normal refresh (ctr+r) everything works fine.
I'm not really sure how to debug this. Any thoughts?
Update
Turns out it was the AdGuard plugin I had installed in Chrome. Disabling the plugin for my site solved the issue.
It would be nice to understand the possible reasons for why my app was being disrupted by the plugin, for example whether there is something going on internally in my app that is against best practices causing AdGuard to label it as suspicious, or perhaps this is just an idiosyncrasy of AdGuard. Unfortunately AdGuard provides no insights into this - it does not actually report any blocking activity.

I got error when I use ngPrint

I develop gulp application. there are I use ngPrint for print table.
This is module include,
var myapp = angular.module('myapp', ['ngPrint']);
and html code like this,
<h1 id="printThisElement">Hello Bro!</h1>
<button class="btn btn-primary" ng-print print-element-id="printThisElement">
I use for that development this example.
below my error,
Uncaught Error: [$injector:modulerr] Failed to instantiate module lgps due to:
Error: [$injector:modulerr] Failed to instantiate module ngPrint due to:
Error: [$injector:nomod] Module 'ngPrint' 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.8/$injector/nomod?p0=ngPrint
at http://localhost:8000/vendor/angular.js:68:12
at http://localhost:8000/vendor/angular.js:2005:17
at ensure (http://localhost:8000/vendor/angular.js:1929:38)
at module (http://localhost:8000/vendor/angular.js:2003:14)
at http://localhost:8000/vendor/angular.js:4435:22
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at http://localhost:8000/vendor/angular.js:4436:40
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=ngPrint&p1=Error%3A…dModules%20(http%3A%2F%2Flocalhost%3A8000%2Fvendor%2Fangular.js%3A4419%3A5)
at http://localhost:8000/vendor/angular.js:68:12
at http://localhost:8000/vendor/angular.js:4458:15
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at http://localhost:8000/vendor/angular.js:4436:40
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at createInjector (http://localhost:8000/vendor/angular.js:4344:11)
at doBootstrap (http://localhost:8000/vendor/angular.js:1676:20)
at bootstrap (http://localhost:8000/vendor/angular.js:1697:12)
http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=lgps&p1=Error%3A%20…otstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fvendor%2Fangular.js%3A1697%3A12)
How I solve that question I try lots way but I can't get result.
The error suggests angular cant find ngPrint module. Did you include the required js files ?
<link rel="stylesheet" href="https://cdn.rawgit.com/gilf/ngPrint/master/ngPrint.min.css" />
<script src="https://rawgit.com/gilf/ngPrint/master/ngPrint.min.js"></script>
Cheers

Constant accessible from all modules

I'd like to have constant that is accessible from my other modules.
I tried something like below, but there's exception.
How should I modify my code to make it work?
angular.module('starter', ['starter.Authentication'])
.constant('baseUrl', 'http://myUrl/api/');
angular.module('starter.Authentication', ['baseUrl'])
.factory('AuthenticationService',
['baseUrl',
function (baseUrl) {
var service = {};
return service;
};
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.Authentication due to:
Error: [$injector:modulerr] Failed to instantiate module baseUrl due to:
Error: [$injector:nomod] Module 'baseUrl' 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.
Change:
angular.module('starter.Authentication', ['baseUrl'])
To:
angular.module('starter.Authentication', ['starter'])
This is because starter is a module that holds the baseUrl constant.

xdomain net::ERR_NAME_NOT_RESOLVED

I am writing AngularJS application and using xdomain (https://github.com/jpillora/xdomain) proxy for CORS REST service.
Everything works fine and erros are handled correctly excpet one case - when proxy.html required by xdomain library is not accesible (network or server error)
In that case I get:
GET https://server.test.pl:41012/proxy.html net::ERR_NAME_NOT_RESOLVED
getFrame xdomain.js:520
(anonymous function) xdomain.js:616
facade.send.process xdomain.js:446
facade.send xdomain.js:449
(anonymous function) angular.js:8521
sendReq angular.js:8315
$HttpProvider.$get.serverRequest angular.js:8049
deferred.promise.then.wrappedCallback angular.js:11520
(anonymous function) angular.js:11606
$RootScopeProvider.$get.Scope.$eval angular.js:12632
$RootScopeProvider.$get.Scope.$digest angular.js:12444
$RootScopeProvider.$get.Scope.$apply angular.js:12736
(anonymous function) angular.js:1438
invoke angular.js:3940
doBootstrap angular.js:1436
bootstrap angular.js:1450
(anonymous function) app.js:86
trigger angular.js:2563
(anonymous function) angular.js:2843
forEach angular.js:325
eventHandler angular.js:2842
I want to intercept this error and handle it but problem is I don't know how:
$http catch/error promise method is not called
httInterceptor i wrote is not invoked
How can I hadle this error?

Angularjs seems to throw meaningless errors

I keep get error logs like this in the console:
ReferenceError {} angular.min.js:60
(anonymous function) angular.min.js:60
(anonymous function) angular.min.js:51
(anonymous function) angular.min.js:88
m angular.min.js:6
e.$broadcast angular.min.js:88
(anonymous function) angular.min.js:80
i angular.min.js:76
i angular.min.js:76
(anonymous function) angular.min.js:76
e.$eval angular.min.js:86
e.$digest angular.min.js:84
e.$apply angular.min.js:86
e angular.min.js:92
o angular.min.js:95
q.onreadystatechange angular.min.js:96
I can usually debug it myself, but these stack traces are awfully meaningless.. am I doning somthing wrong or is this just the way it is?
i quote the trace provider :
ReferenceError {} angular.min.js:60
(anonymous function) angular.min.js:60
(anonymous function) angular.min.js:51
(anonymous function) angular.min.js:88
a few things , your error seems related to $http or $resource and AJAX. if you are using anonymous callbacks, name them
for instance :
$http.get("/blop")
.success(function _successGet(){})
.error(function _errorGet(){})
that way , you'll have some clues about the stack trace. instead of (anonymous function) you'll get a ref to _successGet or _errorGet.

Resources