In Angular 4, how to save request parameters in a redirected route?

I have a route redirect to app-routing.module.ts:

{ path: '', redirectTo: '/home', pathMatch: 'full' }

Suppose I have a index.htmlstring <base href="/mysite">inside <head>and the site is visited with a URL example.com/mysite?kiosk=true.

How to save request parameter kiosk=truevia redirection above?

I can get request parameters with this code inside app.component.ts, but only after the route forwarding above is commented out:

ngOnInit(): void {
    this.route.queryParams.first().subscribe((params: Params) => {
        console.log(params);
    });
}

? ? " " - app.component.js, , "/home", ?

+4
1

nav { queryParamsHandling: 'preserve' }. DOM nav queryParamsHandling="preserve" angular 4 . , { preserveQueryparams: true } [preserveQueryParams]="true" DOM

0

Source: https://habr.com/ru/post/1677802/


All Articles