I'm trying to pass some data to my MVC controller from AngularJS but the Customer object is always null on the MVC controller. What am I missing?
Angular
$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; } }
customer.CustomerID
and do post$scope.customer