AngularJS passing data to $http.get request

I have a function which does a http POST request. The code is specified below. This works fine.

 $http({
  url: user.update_path, 
  method: "POST",
  data: {user_id: user.id, draft: true}
 });

I have another function for http GET and i want to send data to that request. But i dont have that option in get.

 $http({
  url: user.details_path, 
  method: "GET",
  data: {user_id: user.id}
 });

The syntax for http.get is

get(url, config)

Can someone help me with this.

A HTTP GET request can't contain data to be posted to the server. However you can add a query string to the request.

angular.http provides an option for it params.

$http({
    url: user.details_path, 
    method: "GET",
    params: {user_id: user.id}
 });

See: http://docs.angularjs.org/api/ng.$http#get

You can pass params directly to $http.get() The following works fine

$http.get(user.details_path, {
    params: { user_id: user.id }
});

You can even simply add the parameters to the end of the url:

$http.get('path/to/script.php?param=hello').success(function(data) {
    alert(data);
});

Paired with script.php:

<? var_dump($_GET); ?>

Resulting in the following javascript alert:

array(1) {  
    ["param"]=>  
    string(4) "hello"
}

angular js get method example:

$http.get("@Url.Action("GetAllProduct", "Ecommerce")").success(function (data) {

    var information = data;
    $scope.Products = information;
}).error(function (data) {
    //
    $scope.Products = 0;
});