Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 对象在使用$resource传递给angularjs中的服务时为null_Asp.net_Angularjs - Fatal编程技术网

Asp.net 对象在使用$resource传递给angularjs中的服务时为null

Asp.net 对象在使用$resource传递给angularjs中的服务时为null,asp.net,angularjs,Asp.net,Angularjs,我从最近几个小时开始一直在做这个,但没有上路。谢谢你提前提供的帮助 我的合同代码: [WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Employee", BodyStyle = WebMessageBodyStyle.Wrapped)] [OperationContract] void PutEmployeeAccount(Employee obj); 我的服务代码 public

我从最近几个小时开始一直在做这个,但没有上路。谢谢你提前提供的帮助

我的合同代码:

[WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Employee", BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
void PutEmployeeAccount(Employee obj);
我的服务代码

public void PutEmployeeAccount(Employee obj)
{
//  obj passed is null
}
我的AngularJS代码

var myApp = angular.module('myApp', ['ngResource']);
myApp.factory('resourceService', function ($resource) {

var src = $resource("../EmployeeService.svc/Employee/:id",
{ id: "@id" },           //parameters default
{
GetData: { method: "GET", params: {}, isArray: true },
GetDataById: { method: "GET", params: { id: 0 }, isArray: true },
Delete: { method: "DELETE", params: { id: 0 }, isArray: true },
Update: { method: "PUT", params: {}, isArray: true },
save: { method: "PUT", params: {}, isArray: false }
});
return src;
});

function EmployeeCtrl($scope, resourceService) {
var Employee = new resourceService();
Employee.Employeename = 'bar';
Employee.$save();
}
PutEmployeeAccount可以调用web服务。但传递的employee对象为null
如何解决此问题。

通过点击和试用解决问题,设置BodyStyle=WebMessageBodyStyle.Bare已解决此问题。

对您有好处!你也可以接受自己的答案,让别人看到问题已经解决。