我在我的项目中使用了Umbraco
7.3和ASP.NET MVC 5。
我想要从AngularJS
向ASP.NET MVC
5控制器发送数据。
我该如何做呢?
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控制器:
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'
]
}