如何在 Restangular 中创建复杂的查询参数

sma*_*zie 4 rest angularjs restangular

我需要在 Restangular 中创建一个相当复杂的查询字符串。

http://vdmta.rd.mycompany.net//people?anr=Smith&attrs=givenName,displayName,name,cn
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

到目前为止,我可以使用这个来达到 ?anr=Smith:

return Restangular.all('/people').getList({anr:searchTerm});
Run Code Online (Sandbox Code Playgroud)

最后一部分 attrs=x,y,x 让我可以控制我想要在搜索中返回的属性,并且可以根据我提出的请求进行更改。

任何建议表示赞赏。

问候

一世

Dav*_*nce 5

您应该能够简单地添加另一个查询参数,其中值是逗号分隔的属性列表。

var attributes = ['givenName' , 'displayName']; // attributes you require for the request
var attributesAsString = attributes.join();

return Restangular.all('/people').getList({
    anr : searchTerm,
    attrs: attributesAsString
});
Run Code Online (Sandbox Code Playgroud)