Angle POST for ASP.MVC

0

I need to do a POST after a click of a button, so that this POST activates a method in an MVC controller, was testing like this:

[HttpPost]
public void GerarPDF()
{
    string teste = "teste";
}

The name of the Controller is ItemController, and in the button I put the ng-click with the function of the angle:

<button type="submit" ng-click="exibiritem()" class="navbar-btn btn btn-modal"  style="margin-right:0px;" id="btnExibir">
  <center>Exibir</center>
</button>

And in the angle controller:

function exibiritem(){
    $http({
        url: "/item/GerarPDF",
        method: "POST"
    )};
}

I just can not get the function in the MVC controller to run. If someone can help me, I'd be grateful because my angular knowledge is still pretty basic.

    
asked by anonymous 13.03.2017 / 16:23

1 answer

0
 public JsonResult GerarPDF(Objeto objeto) {
    return Json(ObjetoRetorno, JsonRequestBehavior.AllowGet);
   }



$scope.exibiritem= function (objetoEntrada) {
    $http.post('Area/Controller/Action', { objeto: objetoEntrada}).success(function (retorno) {
       $scope.retorno = retorno;
    });
};
    
16.03.2017 / 12:01