I am currently facing a challenge with creating a pre-routeProvider post. The problem I'm encountering is that $http is coming up as undefined, even though I am passing it to the function as per my understanding. I have made sure to declare angular.js before validation.js in the index.html file.
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="components/universal/validation.js"></script>
Here is a snippet from my app.js:
'use strict';
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.test',
'myApp.version'
]).
config(['$routeProvider','$http', function($routeProvider,$http) {
alert ('before call');
var temp = sessionValidation($http);
alert('temp : '+temp);
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
Components/universal/validation.js
function sessionValidation($http) {
alert('before post');
return $http({
url: 'http://255.255.255.255/rip.dll/REST/SESSIONS/',
method: 'POST',
dataType:"json",
xhrFields :{"withCredentials" : true},
data: {'logintype':'1','host':'255.255.255.255','user':'Administrator','password':'1234','controlid':'ABC999'}
})
.success(function (data) {
return data.stats;
})
.error(function () {
return 'Error';
});
}
The browser displays this:
https://i.sstatic.net/pwQs2.png
And here is the error message:
[$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:unpr] Unknown provider: $http...
Full Error Message
I would appreciate any guidance on why $http is not being set. Thank you for your help. Feel free to ask for additional information if needed.