0

Its is my Angular controller

 var app=angular.module('app',[]);

 app.controller('myCtrl', function ($scope,$http) {


console.log($scope.add)

 $scope.asd = function (data)
{
     $http({
         url: '/Home/My',
         method: "GET",
         data: data
     });
}

//console.log($scope.asd);
});

When im passing data like this it is working well

 {
     $http({
         url: '/Home/My',
         method: "GET",
          params: { data: data}
     });
}

Mvc controller

      public ActionResult My(List<string> data)
      {

        return View();
      }

But why couldnt i pass it with "data"?

1 Answer 1

1

Looking at the Angular documentation at https://docs.angularjs.org/api/ng/service/$http , it seems that the "params" parameter refers to data that you want to pass as HTTP GET parameters, while the "data" parameter simply dumps the content into the HTTP request.

Is there a specific reason why you want it to work the first way? If there is not, then the second way appears to be the more elegant choice as it strengthens the interface contract between your Angular and MVC components.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.