Good morning, I have a form in which the values I capture in the need to send them to a controller. This mvc asp.net driver returns a new view as an answer.
My question is, using $ http.post (), can I get that view that the controller returns to me ?. or must I necessarily use the form action from the HTML to get that new view?
Just as I have it, it makes the post request, the controller does what he has to do, but he does not return the new view ().
This is my form:
<div class="jumbotron">
<h1>DATOS</h1>
<p class="lead">Ingrese datos: </p>
<p class="a"> Codigo: <input type="text" id="codigo"/></p>
<p class="badge"> Nombres: <input type="text" id="nombres"/></p>
<p class="caption"> Apellidos: <input type="text"id="apellidos" /></p>
<p class="danger"> Correo: <input type="text" id="correo" /></p>
<p class="help-block"> Estado: <input type="number" id="estado"/></p>
<button ng-click="registrar()" name="registrar"> REGISTRAR </button>
This is the code I have for the request in $ http.post
angular.module("MyApp", [])
.controller("FirstController", function ($scope, $http) {
$scope.registrar = function () {
var req = {
method: 'POST', url: '/Cliente/Create',
data: {
"codigo": document.getElementById("codigo").value,
"nombres": document.getElementById("nombres").value,
"apellidos": document.getElementById("apellidos").value,
"correo": document.getElementById("correo").value,
"estado": document.getElementById("estado").value
}
};
$http(req).then(function (res) {
});
};
});
And this is my driver:
[HttpPost]
public ActionResult Create([Bind(Include = "codigo,nombres,apellidos,correo,estado")] clientes e)
{
clientes q = new clientes();
q.create(e);
return View(q);
}