0
을 사용하여 angularjs에서 서비스에 전달 될 때 객체가 null입니다. 지난 두 시간 동안 작업을하고 있었지만 내 도중에는 작업하지 않았습니다. 사전에 도움을 주셔서 감사합니다.
[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.But 위해 OK입니다 :
내 계약 코드가
null 이 문제를 어떻게 해결할 수 있습니까?
당신에게 좋습니다! 나 자신의 답을 받아 들일 수도 있기 때문에 다른 사람들이 질문이 해결되었음을 알 수 있습니다. – Narretz