I want to get angularjs value from AngularController.js to CCharpController.cs
This I want to sum value from $scope.count1 and $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;
}
}
}
`
and pass to CCharp function like this,
`
[Route("api/WarehousePlan/AllowWarehousePlan")]
[HttpPost]
[Authorize]
public IHttpActionResult AllowWarehousePlan([FromBody] WarehouseAllowDenyModel model){
....
var count = $scope.count1 + $scope.count2 }
`
I expect receive count value from angularjs function.
First declare a model
$scope.modelVM = {};
Then assign the parameter into model as likes you declare in your model class
$scope.modelVM.count1 += 1;
$scope.modelVM.count2 += 1;
After then post the model via http
$http.post('api/WarehousePlan/AllowWarehousePlan', $scope.modelVM).then(
function (successResponse) {
if (successResponse.status == '200') {
alert("Data Submit Successfully..");
}
},
function (errorResponse) {
alert("Not Successful");
});
Set value in Cookie in Controller file,
HttpContext.Current.Response.Cookies["count1"].Value = "1";
You can access cookie value in JS file,
$scope.count1 = $cookies.get("count1");
To Update Cookie value in JS file,
$cookies.put('count1',2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.