我试图从AngularJS传递一些数据到我的MVC控制器,但客户对象在MVC控制器上始终为空。我错过了什么?从AngularJS传递对象到ASP.NET MVC控制器
角
$scope.new = {};
$scope.AddCustomer = function() {
$http.post('/Customer/SaveCustomer', $scope.new).success(function() {
});
}
HTML
<input class="form-control" type="text" placeholder="CustomerID" ng-model="new.c.CustomerID" />
<input class="form-control" type="text" placeholder="CompanyName" ng-model="new.c.CompanyName" />
<button type="button" class="btn btn-primary" ng-click="AddCustomer()">Save</button>
C#
[HttpPost]
public void SaveCustomer(Customer customer)
{
....
}
public class Customer
{
public string CustomerID { get; set; }
public string CompanyName { get; set; }
}
尝试new.CustomerID和new.CompanyName ... – ssilas777
@ ssilas777感谢...这工作...我不知道为什么这个教程中,我经历了它标记为new.c.customerid – Anonymous
啊,似乎@ ssilas777击败了我! – skubski