I am very new about AngularJs, Parse and Karma.This time the problem I meet I didn't search the similar solution online. So I hope anyone good at these parts can help me.
To make the Parse can run in my project, I install the angular-parse-patch from this site: https://github.com/mcwebb/angular-parse-patch
Then it works and I can use Parse in my project.
However, I am doing the unit-test now and when I use Karma test the controller which contains the Parse code. The error generated.
Error: Parse SDK not available
at ngParseProvider.$get (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular-parse-patch/dist/angular-parse-patch.js:1:243)
at Object.invoke (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4523:17)
at C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4340:37
at getService (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4482:39)
at invoke (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4514:13)
at Object.instantiate (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4531:27)
at C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:9197:28
at C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular-mocks/angular-mocks.js:1882:12
at Object.<anonymous> (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/src/app/tab1/main.controller.spec.js:16:18)
at Object.invoke (C:/Users/Administrator.XZ-20140618RVRF/app/my-project/bower_components/angular/angular.js:4523:17)
I guess it caused by the Karma didn't connect the path of the parse-patch.
Related
I'm trying to do upgrade components written in AngularJS1 to Angular6. I'm taking the approach of having the wrappers for all the existing AngularJS1 component by extending "UpgradeComponent" placed under the folder "directive-wrappers" in my example. When I try to add some controllers which doesn't have any directives, I get the error message
Error: [$injector:unpr] Unknown provider: testDirective2DirectiveProvider <- testDirective2Directive
https://errors.angularjs.org/1.7.8/$injector/unpr?p0=testDirective2DirectiveProvider%20%3C-%20testDirective2Directive
at eval (angular.js:138)
at eval (angular.js:4924)
at Object.getService [as get] (angular.js:5084)
at eval (angular.js:4929)
at Object.getService [as get] (angular.js:5084)
at Function.UpgradeHelper.getDirective (upgrade_helper.ts:56)
at new UpgradeHelper (upgrade_helper.ts:52)
at TestDirective2Wrapper.UpgradeComponent (upgrade_component.ts:106)
at new TestDirective2Wrapper (TestDirective2Wrapper.ts:27)
at createClass (provider.ts:265) "<app-root _nghost-c69="">"
I tried adding studentController and homePageController, but not able to load it. Any ideas why I'm facing this issue?
https://stackblitz.com/edit/ng6hybrid-c8h6uv
There are two issues that need to be addressed. First, in the studentController.js file, you are using the var mainApp = angular.module("testApp", []); syntax which is resetting the AngularJS module and everything that got instantiated before is being removed.
To answer your question about the controllers, AngularJS controllers can't be upgraded directly using UpgradeComponent (see https://angular.io/guide/upgrade#using-angularjs-component-directives-from-angular-code) because they aren't components/directives that have a template. That is why the error you get (after fixing the first issue) is Unknown provider: studentControllerDirectiveProvider <- studentControllerDirective. It can't find a directive for the reference studentController, so it is adding Directive to see if that has anything.
To fix this, either convert the controller in AngularJS to a directive with a template, or convert it to a service in AngularJS and then inject it into Angular using the UpgradeModule. Keep in mind you will need a template somewhere for this controller so it can be upgraded to Angular. Please see a working example of this in my stackblitz below.
https://stackblitz.com/edit/ng6hybrid-zs6waw?file=app%2Fdirective-wrappers%2FstudentControllerWrapper.ts
I am getting the error that says
angular.js:13236 Error: [ng:areq] Argument 'fn' is not a function, got undefined
http://errors.angularjs.org/1.5.0/ng/areq?p0=fn&p1=not%20aNaNunction%2C%20got%20undefined
at http://localhost:3000/bower_components/angular/angular.js:68:12
at assertArg (http://localhost:3000/bower_components/angular/angular.js:1825:11)
at assertArgFn (http://localhost:3000/bower_components/angular/angular.js:1835:3)
at Promise.promise.error (http://localhost:3000/bower_components/angular/angular.js:10979:11)
at Object.getUserChannels (http://localhost:3000/scripts/services/media-service.js:38:37)
at activate (http://localhost:3000/scripts/controllers/player-controller.js:63:22)
at new <anonymous> (http://localhost:3000/scripts/controllers/player-controller.js:28:9)
The controller and factory worked before the migration, I cant find any documentation that shows any changes to factories. To me it looks like the controller cannot find the function is the mediaSVC file
Did you check if you used lazy loading of your services and factories in 1.3? If so, please make sure they're loaded in advance before you start calling them when you migrated to 1.5. This was one of the things I've experienced when migrated the large enterprise app from 1.4 to 1.5:
http://www.diatomenterprises.com/migration-history-from-angularjs-1-3-to-1-5-and-then-2-0/
The lazy loading may require a bit of attention and another small library to let it work correctly in 1.5. I can assist you if the problem still exists.
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.
I have angular App defined with following:
var myApp = angular.module('myApp', ['ngRoute','infinite-scroll','geolocation', 'ngAnimate', 'ngTouch','ui.filters', 'AxelSoft','angularLazyImg','wu.masonry','ui.bootstrap','ngSanitize']);
Until now I was using AngularJS version 1.2.14. Now I need to use AngularJS form validations and in order to do that, I have decided to migrate to Angular's latest stable version 1.4.2.
When I have changed the angular version, things got broke and console throws
Uncaught Error: [$injector:modulerr] with following stack trace :
Error: $injector:modulerr
Module Error
Failed to instantiate module myApp due to:
TypeError: Cannot read property 'push' of undefined
at http://localhost:8000/static/mobile/js/angularApp/app.js:6:37
at Object.e [as invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:39:156)
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:328)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:452
at m (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:7:322)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:229)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:398
at m (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:7:322)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:229)
at eb (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:40:503
I have tried reading and understanding angularJS official migration guide but I coudn't able to figure out what's in it for me as I haven't used $animate in my code(It $animate and $touch are injected only for another plugin to work i.e. sliders and also I have used 'ngROute anywhere')
Does anyone have idea what should be done here as I have no idea about where do I start :)
So here is what was needed to be done to migrate my angular Application.
Migrate ngRoute and ngAnimate with the same version of angular
Remove HTTP interceptors which was in 1.2 and change them to the style of angular 1.4
In my case, removing $httpProvider and migration ngAnimate and ngRoute had solved my problem.
Using Karma to test Angular getting error:
Error: [$injector:modulerr] Failed to instantiate module ngMock due to:
Error: [$injector:unpr] Unknown provider: $$rAFProvider
Angular mock, Angular versions error?
I've heard solutions detailing changing of angular-mock version or angular version--which seems like a bad idea since I'd like to test on the same version as the app starts with.
Anyone else have an error like this?
Please check your angular version.
Your angular version and angular-mock version must be same.
To download angular-mock go the below link and replace the X.Y.Z with your angular version and save it
http://ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-mocks.js
for example my angular version is 1.2.9
This work for me .
This issue was resolved by making sure the rails asset pipeline, which provides the angular-related assets in my case, was correctly serving assets during testing.