如何使用Restangular调用自定义查询URL?

问题描述:

我想使用Restangular customGET方法在查询参数中使用特殊字符调用URL。我为我的API使用Loopback,它使用方括号进行查询。看来它在Restangular中是不允许的。如何使用Restangular调用自定义查询URL?

我想打电话给下面的URL。

/api/v1/employees/findOne?filter[where][salesCode]=SC2 

或这但不知道如何。

/api/v1/employees?filter[where][salesCode]=SC2 

我试着跟着没有成功。

Restangular.all("employees").customGET("findOne", {filter + "%5Bwhere%5D%5BsalesCode%5D": newValue}); 

Restangular.all("employees").customGET("findOne", {filter[where][salesCode]: newValue}); 

由于周围的工作我使用$http但黑客是一天一个黑客结束。

你应该这样做:

Restangular.all("employees").customGET("findOne", {"filter[where][salesCode]": newValue}); 

应该这样做:)。

+1

完美!!!非常感谢@mgonto – fusionstrings