0

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.

2

2 Answers 2

1

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"); }); 
    0

    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); 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.