0

I want to implement the routing functionality in Angular 9 however it is not straight forward with url routing in the address bar. Below is the sample code

<ng-container>
  <ul>
    <li>Home Page</li>
    <li><a href='http://localhost:2000/Report1.html?a=1&b=1&c=1&d=2'>Report1</a></li>
    <li><a href='http://localhost:2000/Report2.html?a=1&b=1&c=1&d=2'>Report2</a></li>
    <li><a href='http://localhost:2000/Report3.html?a=1&b=1&c=1&d=2'>Report3</a></li>
    <li><a href='http://localhost:2000/Report4.html?a=1&b=1&c=1&d=2'>Report4</a></li>
  </ul>
  <div> 
     -- content here--
  </div>
</ng-container>

How do I route to different pages based on the user response and show them in the above given div tag?

Once the page is routed how do I get the parameters while the page is loaded?

enter image description here

0

1 Answer 1

0

try this

<a [routerLink]="['report1']" [queryParams]="{a:'1', b: '2'}"></a>
<a [routerLink]="['report2']" [queryParams]="{a:'1', b: '2'}"></a>

you should have report1 and report2 routes specified in your RouterModule

this question answers should help you deeper How to handle query parameters in angular 2

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.