1
當我在我的Angular應用程序中從我的MVC項目返回一個雙/二維數組時,它只返回一個數組。如何從我的MVC控制器返回一個雙數組到我的Angular應用程序?Angular,http返回double int數組
function getStatusView() {
dataFactory.getStatusView()
.then(function (response) {
$scope.statusview = response.data.StatusViewList;
$scope.modelList = response.data.ModelList;
$scope.modelClustersList = response.data.ModelCLustersList;
$scope.turbineNumberDistinct = response.data.TurbineNumbersDistinct;
$scope.alarmArray = response.data.statusArray;
}, function (error) {
$scope.status = 'Unable to load customer data: ' + error.message;
});
}
[HttpGet]
public JsonResult GetStatusView()
{
model.statusArray = new int[model.ModelList.Count, model.StatusViewList.Count];
var statuslinesWithAlarm = statusView.Where(p => p.AlarmLevel> 0).ToList();
foreach (var statuslineWithAlarm in statuslinesWithAlarm)
{
var turbineIndex = model.StatusViewList.Select(p => p.TurbineNumber).ToList().IndexOf(statuslineWithAlarm.TurbineNumber);
var modelIndex = model.ModelList.IndexOf(statuslineWithAlarm.ModelName);
model.statusArray[modelIndex,turbineIndex] = 1;
}
return Json(model, JsonRequestBehavior.AllowGet);
}
你真棒!謝謝! – NatJJ