我有以下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个计数,但所有属性都为空或默认。