Michael Michael - 5 months ago 20
AngularJS Question

How to send POST in angularjs with multiple params?

I want to send multiple parameters using angularjs HTTP post service.

Here is client side code:

$http.post("http://localhost:53263/api/Products/", [$scope.product, $scope.product2]).
then(function (data, status, headers, config) { alert("success") },
function (data, status, headers, config) { alert("error") });


Here is server side code:

// POST api/<controller>
public void Post([FromBody]Product product,[FromBody]Product product2)
{
var productRepository = new ProductRepository();
var newProduct = productRepository.Save(product);
}


But when I make the post I get error.
Any idea what I am doing wrong?

Answer
 var Indata = {param:'val1',.....}
    $http({
    url: "time.php",
    method: "POST",
    params: Indata
    })
Comments