我有一些过滤器,当它们被检查时,它们会在同一个queryParam下的url中应用一个id。我使用router.navigate
方法。我可以将它们显示为如此列表:
http://localhost/view/?opts=1-1 // one filter selected
http://localhost/view/?opts=1-11-2 // two filters selected
但是我喜欢这个网址,或者特别是查询参数'由&符号&'分隔的价值。像这样:
http://localhost/view/?opts=1-1&1-2 // two filters selected
这是我目前的代码:
this._router.navigate([routeUrl], { queryParams: {opts: filterParams}});
我已尝试将filterParams
设置为数组,但这只是重复属性值。是否有Angular方法来实现这一点,还是需要回归JS或jQuery?
答案 0 :(得分:0)
根据 the documentation ,如果您想使用Angular阅读您的网址参数,则应使用 matrix notation <提出的Tim Berners-Lee / strong>即可。
如果您的路由策略无法识别您的网址参数,它们将显示为可选参数,以矩阵样式编写。
如果您决定以自己的方式行事,则需要手动解析网址以获取参数。