簡體   English   中英

Angular.js-$ http成功與然后

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM