AngularJS passing data to $http.get request

2018-12-31 19:45发布

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 don't 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?

7条回答
倾城一夜雪
2楼-- · 2018-12-31 20:20

For sending get request with parameter i use

  $http.get('urlPartOne\\'+parameter+'\\urlPartTwo')

By this you can use your own url string

查看更多
登录 后发表回答