How to call a component from 2 diiferent routes in angular?

35 views Asked by At

I have a userDetails component that can be accessed from two different pages in my application.

It can be accessed from searchUser component and I have a "my account" menu in the header that is available across the application and it is in MenuComponent. I should take the user to the user details page from search page as well as my account menu. I'm using router.navigate to navigate to the details page. It's working fine from the search results page.

However, when I click the "My account" link it is hitting the userDetails component and when it hits the function that calls the service to fetch the data it is not calling the API and comes out of the function and takes me to the homepage. The URL is same from both the places.
I used console.log to log the activatedroute.routeconfig.path, it is /users/:userId when I call from search results and /home when I call from MyAccount link.
Where am I going wrong?

0

There are 0 answers