我想使用像这样的lb-services对angularjs进行多重过滤
MasterTrip.find({ 'filter[include]':'froms',
'filter[include]':'tos',
'filter[include]':'trips'},function(respon){
console.log(respon);
$scope.masters = respon;
});
但是我收到了此错误消息
未捕获的SyntaxError:对象文字中的重复数据属性不是 允许在严格模式下
如何解决这个问题。做多重过滤的替代方案吗?
答案 0 :(得分:4)
您可以使用与服务器端代码相同的基于javascript-object的语法:
MasterTrip.find(
{ filter: { include: ['froms', 'tos', 'trips'] } },
function(respoonse) {
// etc.
});
该URL将包含一个查询参数filter
,其中包含该对象的JSON表示形式。如果您希望保持扩展的URL查询,可以使用以下代码:
MasterTrip.find(
{ 'filter[include]': ['froms', 'tos', 'trips'] },
function(response) {
// etc.
});