Javascript Angularjs-$http成功vs then
我想问一下这种方法的区别 我关心的是。然后和。成功,功能和。错误之间的区别 谢谢 及Javascript Angularjs-$http成功vs then,javascript,angularjs,api,angular-promise,angular-http,Javascript,Angularjs,Api,Angular Promise,Angular Http,我想问一下这种方法的区别 我关心的是。然后和。成功,功能和。错误之间的区别 谢谢 及 .then()和.suces()都是指承诺它异步运行并等待响应(如果它满足了您的请求),然后解决它,否则拒绝它 .success和.error不推荐使用。您可以找到有关文档的更多详细信息不要使用success和error,使用then和catch。.success和.error不推荐使用。请在此处查找承诺文档:可能重复的 // Simple GET request example: $http({ met
.then()
和.suces()
都是指承诺它异步运行并等待响应(如果它满足了您的请求),然后解决它,否则拒绝它
.success
和.error
不推荐使用。您可以找到有关文档的更多详细信息不要使用success和error,使用then和catch。.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.
});