Angularjs - $ http成功与当时

时间:2016-07-28 05:18:34

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

我想问一下这种方法的区别 我关注的是.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.
});

1 个答案:

答案 0 :(得分:6)

String form1_text = form1textbox.getText(); form2.form2textbox.setText(form1_text); .then()都是指承诺它异步运行并等待响应,如果它已满足您的请求,则.sucess()否则resolve它。

不推荐使用

reject.success,您可以找到有关文档的更多详细信息