【发布时间】:2019-06-02 21:28:58
【问题描述】:
我想从 AngularController.js 获取 angularjs 值到 CCharpController.cs
我想将 $scope.count1 和 $scope.count2 的值相加
`
$scope.onSubmit = function () {
for (var i = 0 ; i < $scope.Data.length ; i++) {
if ($scope.Data[i].1 === true) {
$scope.count1 += 1;
}
else if ($scope.Data[i].2 === true) {
$scope.count2 += 1;
}
}
}
`
并像这样传递给 CCharp 函数,
`
[Route("api/WarehousePlan/AllowWarehousePlan")]
[HttpPost]
[Authorize]
public IHttpActionResult AllowWarehousePlan([FromBody] WarehouseAllowDenyModel model){
....
var count = $scope.count1 + $scope.count2 }
`
我希望从 angularjs 函数接收计数值。
【问题讨论】:
-
你需要使用调用你的 api 端点的服务看这里:lullabot.com/articles/processing-forms-in-angularjs
-
您可能需要以计数值作为参数向 API URL 发出
HttpPost请求,然后您的 C# 控制器将接收它作为参数。
标签: c# angularjs asp.net-web-api