You need to implement a feature where clicking on a user's name in a list navigates to a detailed user profile page. The user ID needs to be passed in the URL. How would you implement this using Angular's router?

  • Create a custom directive to handle the navigation and pass the user ID.
  • Define a route with a parameter like /user/:userId and access the userId using ActivatedRoute.
  • Store the user ID in a global service and retrieve it when navigating to the user profile page.
  • Use a query parameter to pass the user ID in the URL and retrieve it using the QueryParams.
To navigate to a detailed user profile page with the user ID in the URL, you should define a route with a parameter like /user/:userId and access the userId using ActivatedRoute.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *