如下所示:
$http.get("/merchantmall/merchant.json")
.success(function(data, status, headers, config) {
console.log(arguments);
})
.error(function(data, status, headers, config) {
console.log(arguments);
})
$http({url: "/merchantmall/merchant.json", })
.success(function(data, status, headers, config) {
console.log(arguments);
})
.error(function(data, status, headers, config) {
console.log(arguments);
})
var promise = $http({
method: 'GET',
url: '/api/users.json'
});
promise.then(function(resp) {
// resp是一个响应对象
}, function(resp) {
// 带有错误信息的resp
});
var promise = $http({
method: 'GET',
url: '/api/users.json'
});
promise.success(function(data, status, headers, config) {
// 处理成功的响应
});
promise.error(function(data, status, headers, config) {
// 处理非成功的响应
});
以上这篇angularjs $http调用接口的方式详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
上一篇 :
优步现在使用手机的传感器来检测你是否遇到了车祸
下一篇 :
Otter现在可以自动转录直播视频
-
容器服务-Kubernetes知识图谱
2026-05-17栏目: 教程
-
如何查看使用 Cloud Toolkit 部署应用的实时日志
2026-05-17栏目: 教程
-
消灭 Java 代码的“坏味道”
2026-05-17栏目: 教程
-
都听我的,会养猪种菜的工程师最帅了!
2026-05-17栏目: 教程
-
使用Bean Validation 2.0定义方法约束
2026-05-17栏目: 教程
