【问题标题】:Angularjs - $http success vs thenAngularjs - $http 成功与然后
【发布时间】:2016-07-28 05:18:34
【问题描述】:

我想问一下这个方法的区别 我关心的是 .then 和 .success、function 和 .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.
});

【问题讨论】:

标签: javascript angularjs api angular-promise angular-http


【解决方案1】:

.then().sucess() 都是指承诺它异步运行并等待响应,如果它满足您的请求,则 resolve 它否则 reject 它。

.success.error 已弃用,您可以在文档中找到更多详细信息

【讨论】:

    猜你喜欢
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 2015-03-16
    • 2014-06-27
    • 2015-11-12
    • 2014-08-09
    • 2015-11-16
    相关资源
    最近更新 更多