[英]Concatenate Query Params as string - Angular- Typescript
I'm trying to concatenate all the query params string that I have into a one final query including all params but I keep getting this result:我正在尝试将我拥有的所有查询参数字符串连接到一个包含所有参数的最终查询中,但我一直得到这个结果:
_filter=0=((startDate=ge=2019-09-30T22:00:00.000Z);(endDate=le=2019-10-
03T22:00:00.000Z));1=
(category=eq=Warning,category=eq=Error);&_limit=50&_sort=asc
with the annoying 0=, 1=, 2=, ....烦人的 0=, 1=, 2=, ....
The expected result is to be like that:预期的结果是这样的:
_filter=((startDate=ge=2019-10-06T12:39:05.000Z;endDate=le=2019-10-
07T23:59:59.999Z);(category=eq=ALERT,category=eq=META))"
Here is my code:这是我的代码:
generateQueryString(obj: any) {
let query = [];
if (obj.startDate && obj.endDate) {
query = query.concat(this.buildDateQueryString(obj.startDate, obj.endDate)
);
}
if (obj.category) {
query = query.concat(this.buildCategoryQueryString(obj.category));
}
return query;
}
const userData = {
firstName: 'Arpit',
lastName: 'Patel'
}
this.router.navigate(['/dashboard/details'], { queryParams: { user: JSON.stringify(userData) } });
this.route.queryParams.subscribe(params => {
const user= JSON.parse(params.user);
console.log(user);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.