我正在使用 ng-resource 通过以下方式访问 API:
$resource('http://' + config.server.api + config.server.host + base_url + '/:id', {
'id': '@id'
},{
'get' : {
method : 'GET'
},
'add' : {
method : 'PUT'
},
'update' : {
method : 'POST'
},
'all' : {
method : 'GET',
isArray : true
},
'del' : {
method : 'DELETE'
}
},{
stripTrailingSlashes : false
});
我正在访问这样的资源:
apiService.Businesses.query(function(data){
$scope.businesses = data;
});
但是,请求 URL 是:http: //API_URL.com/businesses/ :id
或者当我尝试使用“resource.get”时:
apiService.Businesses.get({id:1}, function(data){
$scope.businesses = data;
});
请求 URL 为http://API_URL.com/businesses/:id/[object%20Object]
我显然在资源定义中遗漏了一些东西,但我无法弄清楚它是什么