Not able to use ng-lodash with restangular - angularjs

I am trying to use ngLodash with restangular but i m not able to succeed. Below is the error:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.5/$injector/modulerr?p0=portalApp&p1=Error%…A7080%2FNetworkInsight%2Fstatic%2Fjs%2Fangular%2Fangular.min.js%3A19%3A381)
I am able to use restangular with lodash and underscore successfully .
Below is the code:
angular.module('testApp', ['ngLodash', 'restangular']);
The code does not run when i include the below files
ng-lodash.min.js and restangular.min.js
but when i add underscore-min.js the code starts running successfully.
Restangular needs underscore or lodash to run. But restangular is not able to find lodash when we include it as angularized lodash(ngLoad)
Thanks.

Related

"Backand is not defined" after angular js quickstart

I get this error when I'm trying to use simple CRUD action
ReferenceError: Backand is not defined
I did everything step by step like they requested but something is wrong and I can figure out what... thanks!
Ensure you do this stuffs:
Add backand sdk as script in your index.html files.
src="//cdn.backand.net/backand/dist/1.8.2/backand.min.js"
Add 'backand' as angular module dependency
angular.module('YOUR-APP-NAME', ['backand'])
In your controller add Backand with 'B' uppercase.
myApp.controller('SimpleController', function(Backand){
})

how to do unit testing for angularJs service using karma?

I have a service named "dataService" which is used to get json data from url.This dataService returns some jsonData.Now after running "grunt test" I am getting error like "urlRoot normalized to '/karma/' and client args should be array of strings".Can anyone help me to solve this.
Use the following process:
Define the URL in your package.json
Require grunt in karma.conf.js
Reference the URL via grunt.readJSON
Use array.concat to construct the files array

Angular-mocks Uncaught TypeError, reason for this error

I'm setting up a standard (but simpler) test environment for an Angular app. What I'm using is Mocha, Chai, Angular, Angular-Mocks (since that's needed unless you use Jasmine afaik).
Angular and angular-mocks are version 1.3.10, but this happens for 1.3.15 as well, these are the two versions I tested with.
The problem is that I receive this error from the js console when loading the angular-mocks script.
Uncaught TypeError: undefined is not a function
The lines it's complaining about in angular-mocks is:
(window.beforeEach || window.setup)(function() {
currentSpec = this;
});
So angular-mocks is trying to grab a global function which doesn't exist in this case, right? Why, and how do I prevent it? Is there a actual problem?
Here's a js fiddle with the code and the problem
I then get the following error when trying to use inject()
Uncaught ReferenceError: inject is not defined
Why is this happening?

Unit testing a service in angularJS

I'm relatively new to unit testing but was now tasked to write tests for a existing code base that I know quite well.
Sadly I'm unable to achieve any progress what so ever nor find really helpful documentation.
The main component of the code base is a service to retrieve data from an api but I'm unable to get an instance of the module the service belongs to:
TypeError: module is not a function in /home/faebser/workspace/GridSense-CMS-App/dev/test/unit/api.test.js (line 13)
karma config: http://sprunge.us/ObSP?js
tests: http://sprunge.us/AJWL?js
karma output: http://sprunge.us/WYHI?bash
What is the problem? why am I not able to get a instance of the module?
UPDATE1:
I'm managed to load my module by reinstalling the same version of angular and angular mocks. But now I run into the following error:
minErr/<#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:63:12
loadModules/<#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4138:15
forEach#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:323:11
loadModules#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4099:5
createInjector#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4025:11
workFn#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular-mocks/angular-mocks.js:2425:44
I managed to track the error down to the following:
"[$injector:modulerr] Failed to instantiate module ui.router due to:[$injector:nomod] Module 'ui.router' 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.15/$injector/nomod?p0=ui.routerminErr/<#http://localhost:9876/base/bower_components/angular/angular.js:63:12module/<#http://localhost:9876/base/bower_components/angular/angular.js:1774:1ensure#http://localhost:9876/base/bower_components/angular/angular.js:1698:38module#http://localhost:9876/base/bower_components/angular/angular.js:1772:1loadModules/<#http://localhost:9876/base/bower_components/angular/angular.js:4115:22forEach#http://localhost:9876/base/bower_components/angular/angular.js:323:11loadModules#http://localhost:9876/base/bower_components/angular/angular.js:4099:5loadModules/<#http://localhost:9876/base/bower_components/angular/angular.js:4116:40forEach#http://localho"
Okay, simply forgot to add ui-router to karma-config.
It's looks like angular-mock is not loaded.
Checks well your path. For the moment, for karma it's look like :
-dev
|-test/
|-js/
|-bower_components/
|-karma.conf
Because in karma.conf, you have :
base: '',
Okay, I managed to get this to work.
The main problem was the strange error messages that angular gave me:
minErr/<#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:63:12
loadModules/<#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4138:15
forEach#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:323:11
loadModules#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4099:5
createInjector#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular/angular.js:4025:11
workFn#/home/faebser/workspace/GridSense-CMS-App/dev/bower_components/angular-mocks/angular-mocks.js:2425:44
To work around this I used the karma debug window and set a breakpoint at angular.js:63 in function minErr(module, ErrorConstructor):
return new ErrorConstructor(message);
that way you can see the arguments and the compiled error message. In the end i just forgot to add a few dependencies in the karma config file.

Why does this Angular module/factory injection code work in JS Fiddle but not on my local computer?

I have a JS Fiddle here: Angular module injection. I also have a respository here that from what I can tell, duplicates my code: Blink-Example
When I open index.html I get the error:
Error: Unknown provider: fromBadFactoryProvider <- fromBadFactory
I'm trying to inject a module into my app that has a factory on it and use that factory in the app, but always get this error. What am I doing wrong?
It's because your copy of 1.0.6 is mangled -- you deleted an asterisk from it on line 1128.
Edit: Another reason to use a shared CDN. :)

Resources