我$http在AngularJs中使用,我不确定如何使用返回的promise并处理错误.
我有这个代码:
$http
.get(url)
.success(function(data) {
// Handle data
})
.error(function(data, status) {
// Handle HTTP error
})
.finally(function() {
// Execute logic independent of success/error
})
.catch(function(error) {
// Catch and handle exceptions from success/error/finally functions
});
Run Code Online (Sandbox Code Playgroud)
这是一个很好的方法吗,还是有更简单的方法?