I am facing a challenge in sending a complex object from Angular to my web API. Here is how the object looks:
{
Name: "test",
Tax: 23,
Addresses: [ {
country: "ro",
city: "bucharest"
},
{
country: "fr",
city "paris"
}]}
On the server side, I have a model that looks like this:
public class Model {
public Model (){
Addresses = new List<Address>();
}
public string Name {get; set;}
public int Tax {get; set;}
public List<Address> Addresses {get; set;}
}
The Address class has 2 string properties.
In my previous application using MVC5 and AngularJS $http service, the object mapping worked perfectly. However, after transitioning to MVC6 (ASP.NET 5), I am facing an issue where the object on the server side is NULL when I include the array in my JavaScript object. If I remove the array, it works fine. How can I send an array as an object property from AngularJS using $resource service to an MVC6 controller?