我有查询参数的问题 . 每个路由器都有一个不同的queryParams .
$ stateProvider允许在$ state中定义queryParams
.state('contacts.list', {
templateUrl: 'contacts.list.html',
url: '/test?test1&test2'
data: {
customData1: 44,
customData2: "red"
}
})
此代码允许从queryParams获取test1和test2字段 .
关于新的Angular路由器,如果我需要查看queryParams,我应该订阅
this.activatedRoute.queryParams.subscribe(params => {
});
这段代码有问题,如果我输入url某些第三方test3 = lol,我会在参数参数中得到这个参数,我不想在所有地方过滤它
如何在Angular 5路由器中设置'/ test?test1&test2'
1 回答
网址将是这样的 .
http://localhost:4200/products?order=popular&price-range=not-cheap
在组件构造函数中
希望这可以帮助 . 使用this来回答你的问题 .