Reputation:
Not sure why this is a problem
I have get error on $http
Index.html // References to files
<script src="common/services/common.services.js"></script>
<script src="common/services/deviceService.js"></script>
common.services.js // I'm not using ngResource /$resource for $http obviously do I need to use httpprovider ?
(function () {
"use strict";
angular
.module("common.services", // name of module
["ngResource"]) // array that defines the dependencies ( ngResource contains the $resource service)
} ());
PROBLEM is here...
deviceService.js
(function () {
"use strict";
angular
.module("common.services")
.factory("deviceService",
["$http",deviceService]);
function deviceService($http) {
function httpGetCost(cost, amount, $http) {
$http.get('../api/deviceEvents.json')
.then(function (result) {
//.......
}
return { outsideCall: httpGetCost }
}
} ());
Upvotes: 0
Views: 313
Reputation: 8478
Because you did not inject your $http
properly - just a minor syntax error.
(function() {
"use strict";
angular
.module("common.services")
.factory("deviceService", ["$http", deviceService]);
function deviceService($http) { //this is the real $http that gets injected
function httpGetCost(cost, amount) { //remove your $http here
$http.get('../api/deviceEvents.json')
.then(function(result) {
//.......
}
return {
outsideCall: httpGetCost
}
}
}());
Upvotes: 1