I've used Umbraco
7.3 and ASP.NET MVC 5 in my project.
I want to Send data from AngularJS
to ASP.NET MVC
5 controller.
How can I do it?
reply.html :
<div ng-controller="Reply.controller">
<input type="button" name="Send Reply" ng-click="SendReply()"/>
</div>
Reply.controller.js:
angular.module("umbraco")
.controller("Reply.controller", function ($scope) {
$scope.SendReply = function () {
var SendTo = $("#Email").val();
var TextMessage = $("#TextMessage").val();
//TODO: It's need to write some codes to handle data to an action in ASP.NET MVC controller.But how?
}
});
ASP.NET MVC controller:
public class IncomingCallSurfaceController : BaseSurfaceController
{
public ActionResult Reply(SendMailModel sendMailModel)
{
//TODO: how I should be write this method that be proper for getting data from angularjs?
return null;
}
}
SendMailModel:
public class SendMailModel
{
public string TextMessage { get; set; }
public string SendTo { get; set; }
}
package.manifest:
{
propertyEditors: [
{
alias: "Send.Reply",
name: "Send Reply",
editor:{
view:"/App_Plugins/Reply/Reply.html"
},
}
]
,
javascript:[
'/App_Plugins/Reply/Reply.controller.js'
]
}