I have developed a PWA angular app for mobile, the angular router with query params is working fine in android phones but not working in IOS phones. ** this.router.navigate(['/abc'], { queryParams: { id: id} }); **
CodePudding user response:
Can you share any errors you are getting for the path match? Also, you can try the following instead.
this.router.navigateByUrl('abc');
For maintaining a previous router
this.router.navigate(['/logout',{routeFrom: this.router.url}]);
CodePudding user response:
What is id: id
? If it's a string wrap the left id in quotes. If it's a variable add this.
up front. Also I think the dash /
is not necessary on url.
this.router.navigate(['abc'], { queryParams: { id: 'id'} })
Here is an example: https://stackblitz.com/edit/angular-navigate-with-query-params-dup5cg?file=src/app/app.component.ts
From my example as template url.
<a [routerLink]="['/authenticate']" [queryParams]="{ jwt: 'myID'}">Authenticate</a> | <a routerLink="/home">Home</a> |
And using navigate()
//html
<button (click)="navigate()">Navigate to Authenticate</button>
constructor(private router: Router) {}
navigate() {
this.router.navigate( ['authenticate'], { queryParams: { jwt: 'myID'}});
}