Implement noUiSlider in a view template - AngularJS - angularjs

I'm new to AngularJS.
I want a range slider(noUiSlider) on a Angular view.
I found these 2 libraries to achieve that:
1) https://github.com/vasyabigi/angular-nouislider (Angular plugin)
2) https://github.com/Yankovsky/nouislider-angular (Angular plugin)
I chose option (2) and followed each steps exactly as mentioned there. But I'm getting this error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module fastrankApp due to:
Error: [$injector:unpr] Unknown provider: $stateProvider
Any idea how to solve that? OR can anybody provide steps to implement noUiSlider in AgularJS in detail?
Any help would be appreciated.

do u inject your uislider to your App(same for javascript code in your web footer)?. Btw. its look like that problem is somewhere else.
For slider I use classic Bootstrap Slider
What is your AngularJs version.
Share your code.

Related

Error while loading controllers - migrating AngularJS1 to Angular6

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

Migrating from Angular 1.2.14 to 1.4.2 breaks whole application

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.

'Module ... is not available!' error, when trying to accomplish Angular example on jsFiddle

I'm trying to make an MCVE for my question, but can't get my code working on jsFiddle and get the following error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module carouselApp due to:
Error: [$injector:nomod] Module 'carouselApp' 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.
Link to my example: https://jsfiddle.net/anatoly314/n0qfj4dk/
What am I doing wrong?
UPDATE: This answer from another SO question helped me to solve the issue: https://stackoverflow.com/a/14733670/947111
I recommend you to select values like below to deploy angularjs application on jsFiddle.
And Don't forget to remove angular.js from External Resources.
EDIT:
If there is not the version you want to use, selecting No wrap - in <body> will solve the problem.

Error: [$injector:unpr] Unknown provider: $$rAFProvider

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.

Inject a module in MEAN.io module

I'd like to integrate ui-rangeSlider in a app based on MEAN.io framework.
But I think the problem is the same for any module.
When I add the parameter in the function
angular.module('mean', ['ui-rangeSlider']).controller('PreferencesController', ['$scope', 'Global',
I added the required static ressources in the app.js :
Preferences.aggregateAsset('js', 'angular.rangeSlider.js');
I get an error
Uncaught Error: [$injector:modulerr] Failed to instantiate module mean due to:
Error: [$injector:unpr] Unknown provider: $stateProvider
Do you have any idea ?
Thank you
did you see this? How to implement jQuery range slider in AngularJS
I think you need to pass $stateProvider to your module. Without seeing more code I am not sure, I think it is not finding $stateProvider and is not an error related to the range slider script.

Resources