0

This is what i want:

$http.get('v1/service/:variable', { params: { variable: 'val' } })

so i know that this still just adds the val as a query param, but i want it to replace the :variable. Do you see this happening?

Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125

1 Answers1

1

AngularJS's $http does not support this.

You'll have to do the replacing yourself.

var url = 'v1/service/:variable';
var params = {
    variable: 'val' 
};

for(var varName in params) {
    url = url.replace(':' + varName, params[varName]);
}

$http.get(url);

Or go with a sprintf-like library.

Community
  • 1
  • 1
Sergiu Paraschiv
  • 9,929
  • 5
  • 36
  • 47