【发布时间】:2014-03-03 11:06:12
【问题描述】:
我有这个代码:
MyService.one($routeParams.wuid).doGET('test').then(function(e){
alert('ok');
}, function errorCallback(response){
alert('error');
});
它调用我管理的 API,但只有 alert('ok') 有效,在 404 响应的情况下,不会调用回调我的控制台中有一个 angularjs 错误。
Error: c is undefined this.$get</e/A/v@http://localhost:8888/client/app/js/libs/restangular.min.js:8 Ad/e/k.promise.then/C@http://localhost:8888/client/app/js/libs/angular.min.js:92 Ad/g/<.then/<@http://localhost:8888/client/app/js/libs/angular.min.js:94 Bd/this.$get</h.prototype.$eval@http://localhost:8888/client/app/js/libs/angular.min.js:102 Bd/this.$get</h.prototype.$digest@http://localhost:8888/client/app/js/libs/angular.min.js:100 Bd/this.$get</h.prototype.$apply@http://localhost:8888/client/app/js/libs/angular.min.js:103 f@http://localhost:8888/client/app/js/libs/angular.min.js:67 E@http://localhost:8888/client/app/js/libs/angular.min.js:71 pd/</v.onreadystatechange@http://localhost:8888/client/app/js/libs/angular.min.js:72
我不明白,因为the official doc 说:
如何处理错误?
可以在 then 的第二个参数上检查错误。
Restangular.all("accounts").getList().then(function() {
console.log("一切正常"); }, function(response) { console.log("错误 带状态码", response.status); });
我哪里错了?
【问题讨论】:
-
在我的代码中完美运行。创建一个显示错误的 plunker 或 fiddle,我相信有人会提供帮助。
-
感谢您的回复。我发布了错误的代码,我已经更正了。它是 doGet() 而不是 get(),没有其他变化
标签: angularjs restangular