I am creating a Single Page Application using ASP.NET Web API and AngularJS. The problem is that when I post data from AngularJS controller to API controller, the object is getting passed but all the values of different properties are not those which were assigned but default values.
Model is defined as follows:
public class Expense
{
[Key]
public int ID { get; set; }
public string Description { get; set; }
public int Amount { get; set; }
}
This is the value of object which I passed from AngularJS controller, which I see in the AngularJS JavaScript file breakpoint,
"{"ID":1,"Description":"test","Amount":1000}"
$http.post("/Expenses/Create", $scope.expense);
And this is what it reaches to the controller:
[HttpPost]
[ActionName("Create")]
public IActionResult Create(Expense expenses)`
{"ID":0,"Description":null,"Amount":0}"