Angularjs $ http params with slash

I am using angularjs with slim php and I have a GET action in slim that

action/param1/param2 

Then in my corner js

 $http({ url: 'action', method: 'GET', params:{param1: param1, param2: param2} }).success(); 

Does it return an error in the console using? and &, but I need it to get a slash between the parameters

 http://xxxxxx/action?param=aaa&param2=bbb 

What I tried, I change the parameters of $ http below and it works

  url: 'action/' + param1 + '/' + param2 

Well, my question is: is there a better solution comparable to mine? because i feel stupid.

+4
source share
1 answer

Use $ resource instead:

 var myResource = $resource('action/:foo/:bar', {}, { get: { method: 'GET' } } ); myResource.get({foo:1, bar:2}); 

Call call:

http://yourserver.com/action/1/2

0
source

All Articles