Angular erasing all query parameters

后端 未结 4 1914
失恋的感觉
失恋的感觉 2021-01-07 04:00

Related to but not a duplicate of: How to keep query string parameters in URL when accessing a route of an Angular 2 app?

I have a very basic Angular app, and when I

4条回答
  •  伪装坚强ぢ
    2021-01-07 04:39

    You need to assign your query params to the queryParams Object.

    Try:

    this.router.navigate(['/calculator'], {queryParams: {a: 1}});
    

    or add this to your navigation extras:

    let navigationExtras: NavigationExtras = {
        queryParamsHandling: 'preserve',
        preserveFragment: true,
        queryParams: {a:1}
    };
    

提交回复
热议问题