Angular 1.0.8 $resource with multiple optional get parameters

情到浓时终转凉″ 提交于 2019-12-02 20:51:34

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!