How to use Named Parameters in $ http of AngularJs?

0

Is there any way to use named parameters in the $http of Angular method?

With ngResource you can do this:

var User = $resource('/path/to/user/:id');
$scope.user = User.get({id: 1}, function() {
   $scope.user.name = $scope.user.first_name + ' ' + $scope.user.last_name;
});

Does anyone know a way to do this in the $http method?

    
asked by anonymous 06.11.2014 / 22:52

1 answer

0

$http.get('/someUrl').

URL = 'api/controler/action?parameter1=xxx&parameter2=xxx' - In the case of a webapi2, it depends on the type of server you are consuming.

$http.post('/someUrl', {msg:'hello word!'}).
      then(function(response) {
    // this callback will be called asynchronously
    // when the response is available
  }, function(response) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });
  

The response object has these properties:

     

data - {string | Object} - The response body transformed with the transform functions.

     

Status - {number} - HTTP status code of the

     

response. headers - {function ([headerName])} - Header getter function.

     

config - {Object} - The configuration object that was used to generate

     

the request. statusText - {string} - HTTP status text of the response.

    
12.08.2015 / 05:30