AngularJS $resource の query() メソッドをカスタム $http-GET で上書きしようとしています。ただし、操作の結果を上書きしないようです。method
、data
およびheaders
、notを含むオブジェクトを返しますdata.rows[]
。
angular.module('couchdb', ['ngResource']).
factory('Project', function($resource, $http) {
var Project = $resource('http://couchdb/mydb', {}, {
'update': { method: 'PUT' },
'query': {method:'GET', isArray: false}
}
);
Project.query = function() {
return $http({method: 'GET', url: 'http://couchdb/mydb/_design/projects/_view/index'}).
success(function(data, status, headers, config) {
return data.rows;
}).
error(function(data, status, headers, config) {
$scope.data = data || "Request failed";
$scope.status = status;
});
};
return Project;
});
リソースの結果の行のみを取得するにはどうすればよいですか?