Actually,I want to send an array of json object to .net web api.and I am
doing like this.
It is my .net web api controller.
public void Post(NewCustomer customer)
{
}
where NewCustomer is a class
public class NewCustomer
{
public IList<Customer> Customers { get; set; }
}
and Customer class is like
public class Customer
{
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public int Age { get; set; }
}
and at client side I am using Angularjs,my controller is
app.controller('CustomerListController', function ($scope, customerService)
{
$scope.CustomerList = [{ "CustomerId": 1, "CustomerName": "deeksha",
"Age": 23 }, { "CustomerId": 2, "CustomerName": "pooja", "Age": 34 }];
$scope.Add = function () {
alert(JSON.stringify($scope.CustomerList));
customerService.addCustomer(JSON.stringify($scope.CustomerList));
};
});
and Service is like
var customerAPI = '/api/customer/:Id';
app.factory("Customer", function ($resource) {
return $resource(
customerAPI,
{ Id: "@Id" },
{
"update": { method: "PUT", isArray: true }
}
);
});
app.service("customerService", function ($resource, Customer) {
this.addCustomer = function (customerDetail) {
Customer.save(customerDetail);
};
});
I am not getting where is problem because value is being sent by client
side and I can see it in firebug but server side web api controller is
showing null value.I want solution of it
Thanks in advance to *you* .
On Tuesday, February 18, 2014 9:07:34 PM UTC+5:30, Sander Elias wrote:
>
> Hi Deeksha,
>
> Sure, questions are for free ;)
>
> Regards
> Sander
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.