タグ付けされた質問 「angular-resource」

3
AngularJSで$ resourceサービスエラーを処理する方法
私は自分のAPIにリクエストを出し、AngularJS $ resourceモジュールを使用しています。$ httpとは異なり、エラーの処理方法がわかりません。 私のサービス: var appServices = angular.module('app.services', ['ngResource']); appServices.factory('Category', ['$resource', function($resource){ return $resource('/apicategoryerr/?format=:format', {}, { query: { method: 'GET', params: { format: 'json'}, isArray: true, } }); }]); 私のコントローラー: ... Category.query(function(data) { console.log(data); }); ... 私はこのようなものを望んでいます。私のAPIが機能していない場合にエラーを処理する方法がわかりません。 Category.query().success(function() { console.log('success'); }).error(function() { console.log('error'); });
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.