Matthew Matthew - 7 months ago 110
AngularJS Question

Uncaught ReferenceError: $http is not defined

I'm having a bit of trouble using $http using the AngularJS framework. I've read several of the other posts about this error but I can't work out what I'm doing wrong. Any help would be greatly appreciated. The error is 'Uncaught ReferenceError: $http is not defined' and the code is:

function removePupil(val) {
var string = '';
var pupilNowRemoved = string.replace(val, '');
var data = {
"customer[id]": {{ }},
"metafield[customer.pupils]": pupilNowRemoved,
$'/a/custmeta', $.param(data),
{"headers" : {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}
}).success(function(data, status, headers, config) {
console.log('Removed pupil')
}). error(function(data, status, headers, config) {
console.log('Did not remove pupil')


Try to include $http in your controller like this:

.controller('MyController', ['$http', function ($http) {}];