gpt4 book ai didi

javascript - Uncaught ReferenceError : $http is not defined

转载 作者:行者123 更新时间:2023-12-02 14:25:18 27 4
gpt4 key购买 nike

我在使用 AngularJS 框架使用 $http 时遇到了一些麻烦。我已经阅读了有关此错误的其他几篇文章,但我无法弄清楚我做错了什么。任何帮助将不胜感激。错误是“Uncaught ReferenceError:$http未定义”,代码是:

function removePupil(val) {  
var string = 'Jon:jon@aaa.com:George:george@aaa.co.uk:Matthew:matthew@aaa.com:';
var pupilNowRemoved = string.replace(val, '');
var data = {
"customer[id]": {{ customer.id }},
"metafield[customer.pupils]": pupilNowRemoved,
};
$http.post('/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')
});
}

最佳答案

尝试在 Controller 中包含 $http,如下所示:

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

关于javascript - Uncaught ReferenceError : $http is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38311732/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com