사전에서 JS를 MVC로 전달하려고 시도했습니다. 데이터 (mvc 컨트롤러의 reportIdAndStatus)는 null입니다.Java Script Angular 클라이언트에서 MVC3 서버로 사전을 전달하는 방법
저는 angular $ resource 및 MVC를 사용하고 있습니다. 3. 감사합니다.
각도 컨트롤러 :
var reportStatusdictionary = {};
//build a dictionary
for (var x = 0; x < reports.length; x++) {
reportStatusdictionary[reports[x].Id] = reports[x].StatusId
}
reportsService.getReportStatusComment({ reportStatusdictionary: reportStatusdictionary }
각도 자원 정의 :
getReportStatusComment:
{
method: 'GET',
params: { reportIdAndStatus: '@reportIdAndStatus', command: 'GetReportStatusComment' },
isArray: false
}
MCV 컨트롤러 : 브라우저에서
[HttpGet]
public string GetReportStatusComment(Dictionary<Guid, int> reportIdAndStatus)
요청 :
서버에서 클라이언트로 사전을 보내고 형식을 캡처하여 보내보십시오. – Chandermani
POST metod를 사용하지 않는 이유는 무엇입니까? 내가 리소스를 변경하지 않기 때문에 – sylwester
@ user3314659보다 쉬워야합니다. – MichaelLo