php - Pass Multiple parameters Angularjs resource -


i have usersservice.js

app.factory('usersservice', function($resource) { return $resource('api/users/:id', {}, {     update: {method:'put'}, }); 

along index.php (api php slim framework)

... $app->get('/users/:id', 'getuser'); $app->get('/users/:username', 'getuserbyusername'); function getuser(){ ... } function getuserbyusername(){ ... } ... 

now, when try call somewhere usersservice.get({id:15}); works, when try call usersservice.get({username:'test'}); doesn't work...

i tried every possible way find on google couldn't make work. can make separate service user username, i'd keep in 1 service if possible.

please help, thanks!

you have tell angular $resource value :username.

for more details @ documentation

change yout userservice.js :

app.factory('usersservice', function($resource) {   return $resource('api/users/:id/:username', {id:'@id',username:'@username'}, {     update: {method:'put'} }); 

edit:

how php script know when gets /users/123 should run first route, when gets /users/123joe should run next route? validate somehow? if no, should change routes in php script, more clear.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -