0
저는 각도 컨트롤러에서 ASP.NET MVC 컨트롤러를 호출하는 서버에서 $ 리소스를 사용하여 데이터를 가져옵니다. 값 (십진수 유형?)은 MVC 컨트롤러에서 올바르게 반환되지만 약속이 해결되면 해당 매개 변수는 빈 값이며 예상 값이 아닙니다.
$ 리소스 파일 :
angular
.module('app')
.service('datacontext', function ($rootScope, $resource) {
return {
emissions: $resource('/api/emissions/:id', { 'id': '@id', emissionId: '@emissionId' },
{
create: { method: 'POST' },
lock: { method: 'PUT', url: "/api/emissions/lock" },
getFxRate: { method: 'GET', isArray: false, url: '/api/emissions/getfxrate'}
})
}
ASP.NET MVC 컨트롤러
[HttpGet]
[Route("/api/emissions/getfxrate")]
public async Task<IHttpActionResult> GetFxRate(string currency)
{
var res = await _emissionsAppService.GetFxRateAsync(currency);
//Here I get properly a decimal value as expected. (eg. 1.07123)
return Ok(res);
}
각도 컨트롤러 :
function getRate(currency){
datacontext.emissions.getFxRate({ currency: currency})
.$promise.then(function (result) {
//Here result is just an empty object {}
}
}
서버에서 클라이언트 컨트롤러로 값을 되돌리기 위해 누락 된 부분을 이해할 수 없습니다.