I have a razor partial view which makes use of Ajax.BeginForm. Problem is that I want to handle ajax response via angular controller which is attached to this view. While I can attach custom attributes to inputs using htmlattributes, I couldn't find anything similar for Ajax.BeginForm helper aside from AjaxOptions. But how can I define angular controller method inside it?
upd: I know that OnSuccess etc. ajax events can be handled via regular javascript like below:
<div class="content">
@*@using (Ajax.BeginForm("AccountCheckLogin2", "Login", null, new AjaxOptions { OnFailure = "OnFailure", OnSuccess = "OnSuccess", UpdateTargetId = "result" }, new { @name = "form", role = "form" }))*@
@using (Ajax.BeginForm("AccountCheckLogin2", "Login", new AjaxOptions { OnSuccess = "OnSuccessLogin", OnBegin = "OnBeginLogin", OnComplete = "OnCompleteLogin", OnFailure = "OnFailureLogin" }))
{
//inputs here
}
<a class="link" href="/Registration/Registration">Я не зареестрований</a>
</div>
</div>
<script type="text/javascript">
function OnSuccessLogin(response) {
if (response.ResponseCode == "1") {
window.location = "/";
}
else
{
$("#LoginValidationSummary ul").append("<li>"+response.ResponseMessage+"</li>");
}
}
function OnBeginLogin() {
$("#loginSubmit").prop("disabled", true);
}
function OnCompleteLogin() {
$("#loginSubmit").prop("disabled", false);
}
function OnFailure() {
alert("Whoops! That didn't go so well did it?");
}
</script>
question is, can I handle this events via Angular methods?
<div>
– RicAjax.BeginForm
for what you want to do but rather do everything the angular way and define the controller and attach it to the form – Ric