$ http angular post后mvc viewmodel为空

时间:2014-12-27 03:47:42

标签: angularjs asp.net-mvc-4 http model-view-controller

我有以下mvc viewmodel

public class PersonVM {
    public int Id {get;set;}
    public string Name {get;set;}
    public IEnumerable<DeptVM> Departments {get;set;}
}

public class DeptVM{
    public int Id {get;set;}
    public string Name {get;set;}
}

这是我的帖子功能

$scope.selectedDepartments = [{ Id: 1, Name: 'TestDept'}, { Id:2, Name:'Twoooo'}];

$http({
      method: 'POST',
      url: url,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      data: $.param({
          Id: $scope.personid,
          Departments: $scope.selectedDepartments
      })
}).success(function(data){
});

public ActionResult Edit(int evtId, PersonVM model){

}

在我的ActionResult的帖子中,模型将具有Id和任何其他模型属性,但Departments将有2个计数,但所有属性都为空或默认。

0 个答案:

没有答案
相关问题