angularjs $http調(diào)用接口的方式詳解
更新時間:2018年08月13日 09:04:14 作者:寒山石徑
今天小編就為大家分享一篇angularjs $http調(diào)用接口的方式詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
$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調(diào)用接口的方式詳解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
AngularJS實現(xiàn)一次監(jiān)聽多個值發(fā)生的變化
這文章給大家介紹了如何利用AngularJS一次監(jiān)聽多個值發(fā)生的變化,文中通過示例代碼演示,這樣更方便大家理解學習,有需要的可以參考借鑒。2016-08-08
解決angular的$http.post()提交數(shù)據(jù)時后臺接收不到參數(shù)值問題的方法
這篇文章為大家分享了解決angular的$http.post()提交數(shù)據(jù)時后臺接收不到參數(shù)值問題的方法,感興趣的小伙伴們可以參考一下2015-12-12
解決三元運算符 報錯“SyntaxError: can''''t assign to conditional expre
在本篇文章里小編給大家整理的是關(guān)于python三元運算符 報錯“SyntaxError: can't assign to conditional expression”的處理方法,需要的朋友們學習下。2020-02-02

