Angular 1.0.8 $resource with multiple optional get parameters Angular 1.0.8 $resource with multiple optional get parameters angularjs angularjs

Angular 1.0.8 $resource with multiple optional get parameters


If you need parameters to be mapped to the query parameters, not the path parameters, you shouldn't put the name of parameters into the path. E.g. student resource should look like this:

var Student = $resource('/app/student/',    {});

Then invocation like this will work without any problems:

 Student.get({id:12,courseId:55});//calls /app/student/?id=12&courseId=55 Student.get({id:12});//calls /app/student/?id=12 Student.get({courseId:55});//calls /app/student/?courseId=55

The others cases will work as well. Just don't confuse path parameters with query parameters.