[英]Angularjs - $http success vs then
我想問一下這種方法的區別。我關心的是.then和.success之間的區別,功能以及.error謝謝。
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
和
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).success(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}).error( function(data) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
.sucess()
.then()
和.sucess()
均指的是保證異步運行,並在請求滿足后等待響應,然后resolve
該請求,否則reject
該請求。
.success
和.error
已過時,您可以在文檔中找到更多詳細信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.