在我的资源中,我有以下代码
app.factory('myResource', function ($resource, $http) {
var resource = $resource('http://localhost:1234/api/:pg/:obj', {
pg: '@pg',
obj: '@obj'
},
{
'put': {
method: 'PUT'
},
'get': { method: 'GET' },
'save': { method: 'POST' },
'query': { method: 'GET', isArray: true },
'remove': { method: 'DELETE' },
'delete': { method: 'DELETE' }
}
);
return resource;
});
在控制器中我使用像
var param = { pg: 'MyTask', obj: taskModel }
$scope.TaskId = myResource.put(param);
并且调试数据在obj
中很好,但在模型
public HttpResponseMessage put(MyTask model)
{}
答案 0 :(得分:0)
您的资源已配置为将@pg和@obj序列化为URI。
$ resource(' http://localhost:1234/api/:pg/:obj',{
但WEBAPI会看到MyTask对象(复杂对象)并期望它来自请求体。
更改客户端以包含" obj"数据到请求主体或更改服务器端以使用webapi属性从uri获取模型。这完全取决于" obj"的复杂性。信息。