-1

I wonder add queryParams to url without router.navigateByUrl or routerLink Click in angular

I did not try anything

add Query params to url

June Lee
  • 357
  • 5
  • 16
  • Pls, if you have specific requirements, add more info. your question is quite generic. is it a link in your own application you want to send / get data to or is it an external call to an API. etc – jcuypers Apr 21 '19 at 05:56
  • In angular application, If you use router of angular frameWork, You will use 'Router' of @angular/router module then, If I use routing in application, I will use add [routerLink] to template or execute router.navigateByUrl, But this method change browers url link, I just add query params to url – June Lee Apr 21 '19 at 06:07
  • I understand, but what is it really you want to achieve?? give us a **concrete** example of what you try to do. e.g. page A has X, want to go to page B and I want to transfer some data Z in a certain format. (or i want to trigger something) – jcuypers Apr 21 '19 at 06:09
  • This is not about http request. In my web page, *ngIf is depends on router params. For example https://exampleUrl/sign/loginUp=true => login pop up true https://exampleUrl/sign/loginUp=false => register pop up true – June Lee Apr 21 '19 at 06:17

3 Answers3

2

try add [queryParams] directive

<a routerLink="contact" [queryParams]="{first:fu,last:bar}" >
   Contact
</a>
onik
  • 1,579
  • 1
  • 11
  • 19
0

I solved use same routerLink

<div [routerLink]="'/some'" [queryParams]="{s: 'true'}" ></div>
<div [routerLink]="'/some'" [queryParams]="{s: 'false'}" ></div>
June Lee
  • 357
  • 5
  • 16
0
updateQueryParams(queryParams: Params) {
    this.router.navigate([], {
        relativeTo: this.activatedRoute,
        queryParams,
        queryParamsHandling: 'merge'
    });
}
Young
  • 1