0

I am trying to manually concatenate query parameters into a string and bind the value to routerLink attribute. this is the .ts file:

ngOnInit() {        
    this.href = "data/?project="+this.number+"&item="+this.number2;
}

I than bind it in HTML:

<a class="nav-link" href="#" [routerLink]="[href]">LINK HERE</a>

the issue is that Angular enocdes =, ? & signs into %3F, %3D and %26 and displays that in the link. What should I do to keep =, ? and & unencoded?

1
  • Try using preserveQueryParams attribute on <a Commented Nov 24, 2017 at 19:36

1 Answer 1

1

The answer I went with is to use [queryParams] next to [routerLink].

Example:

<a [routerLink]="[href]" [queryParams]="{project: projectNumber}">Details</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.