对象从角度传递到控制器,显示参数的空值? MVC

时间:2019-04-03 05:39:30

标签: angularjs object model-view-controller query-string

我试图将对象从AngularJS 1.x传递给控制器​​,我的角度代码就像

 var searchCriteria =
                {
                    from: vm.From,
                    to: vm.To,
                    region: vm.SelectedRegion,
                    city: vm.SelectedCity,
                    buildingType: vm.selectedBuildType,
                    buildingid: vm.selectedHospitalID,
                    leaderId: vm.SelectedTeamLeader,
                    teamid: vm.SelectedTeam,
                    userId: vm.SelectedEvaluator,
                    trainerId: vm.SelectedTrainer,
                    status: vm.selectVisitStatus,
                }

将上述对象传递给控制器​​的代码,

var controllerUrl = utilitiesService.getFullPath() + '/Survey/establishmentAllRecord/' + { searchCriteria: searchCriteria };

在控制器端,我正在使用此代码,

public FileResult establishmentAllRecord(object searchCriteria)
{
}

object searchCreiteria中的此控制器上,它显示所有值都为null ??

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您通过$http服务来发出POST请求:

.controller('ctrl', ['$http', function($http){
    //your code...

    $http({
        url: utilitiesService.getFullPath() + '/Survey/establishmentAllRecord',
        method: "POST",
        data: searchCriteria
    });
}])



[HttpPost]
public FileResult establishmentAllRecord(SearchCriteria searchCriteria)
{
}