【发布时间】:2014-12-16 18:34:40
【问题描述】:
我正在使用 Angular 1.2,并且难以处理任何类型的错误。文档说我可以在 save 方法上使用 2 个回调,第一个作为成功回调,第二个作为错误回调。但是,第一个只会被调用。我做错了吗?
var obj = new ResourcefulObjThing();
obj.$save(
function () { alert('success'); }, // no matter the status code, this will get called
function () { alert('failure'); }
);
ResourcefulObjThing.save(
{},
function () { alert('success'); }, // no matter the status code, this will get called
function () { alert('failure'); }
);
var obj = new ResourcefulObjThing();
obj.$save().then(
function () { alert('success'); }, // no matter the status code, this will get called
function () { alert('failure'); }
);
$http
.post('/resourceful/url', {})
.success(function () { alert('success'); } // no matter the status code, this will get called
.error(function () { alert('error'); });
【问题讨论】:
标签: angularjs angularjs-resource