【问题标题】:ngResource.save() not calling errorngResource.save() 没有调用错误
【发布时间】: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


    【解决方案1】:

    原来有一个 httpInterceptor 没有拒绝错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 2020-07-21
      • 2018-01-24
      • 1970-01-01
      • 2016-01-05
      相关资源
      最近更新 更多