0
It’s been a while since I’ve been learning Angular and having some problems. I try to include a service (httpService), but an error occurs. My code:
Controller.js:
'use strict';
var app = angular.module('ang-app');
app.controller('User_Register_EditCtrl', user_register_edit);
user_register_edit.$inject = ['httpService'];
function user_register_edit(httpService){
var ctrl = this;
//variables
//methods
ctrl.backend = backend;
ctrl.saveUser = saveUser;
function backend(){
a = httpService.post('backend.php', {nome: 'carlos', idade: '15'});
console.log(a);
}
function saveUser(){
$('#loading').show();
setTimeout(function(){
console.log('Saving...');
}, 2000);
}
}
Service.js:
'use strict';
var app = angular.module('ang-app');
app.factory('httpService', httpService);
function httpService($http, httpUtils){
var path = './ang-app_webservices';
var http = {};
http.get = get;
http.post = post;
function get(url, params){
queryParams = httpUtils.convertToQueryParams(params);
return $http({
url: path + url + '?' + queryParams,
method: 'GET'
})
}
function post(url, data){
return $http({
url: path + url,
method: 'POST',
data: data
})
}
}
The mistake:
Error: $injector:unpr Unknown Provider
Unknown Provider: httpUtilsProvider <- httpUtils <- httpService