How to pass parameters from Angularjs to code behind

Last Reply on Feb 08, 2016 01:01 AM By uma@asp

Posted on Feb 07, 2016 11:51 PM

How to pass parameters from Angularjs to code behind.

here is code

 $scope.submit = function (item) {
               
                  $http.post('Default.aspx/getstring',{data: item})
                  .success(function (data) {
                      alert(status.d);
                  })
                  .error(function (data) {
                      $scope.status = status;
                  });
              }

 

 

i want to pass parameters 'item' to getstring() web method.

can anyone help me and iam new to angularjs

Thanks in advance

 

 

 

Posted on Feb 08, 2016 01:01 AM Modified on on Feb 08, 2016 01:11 AM

thanks for your response.

As we pass parameter jquery to webmethod like below

"data: "{'selfdata':'" + selfData + "'}""

i need same thing in angularjs

 

 

i found solution as below shown

  var req = {
                      method: 'POST',
                      url: "Default.aspx/getstring",
                      data: "{'selfdata':'" + i + "'}",
                      headers: {
                          'user-Token': 'Token value should b here',
                          'content-Type': 'Application/Json'
                      }
                  }

                  $http(req)
                  .success(function (data) {
                      alert(status.d);
                  })