I am working with two components: CategoryComponent and CategoryProductComponent, as well as a service called CartegoryService. The CategoryComponent displays a table of categories fetched from the CategoryService. Each row in the table has a button that redirects to the CategoryProductComponent, which shows the list of products in that category.
When retrieving JSON data from the API, there is a links array containing rel = category-product with the related product link.
The issue arises when I manually input the URL in the browser, as the link is not fetched by the CategoryComponent. I have tried assigning the link to a variable in the CategoryService, assuming it would persist after the initial assignment due to services being singletons. However, this approach did not solve the problem. What is the best way to handle communication between these components?
In addition, passing the link as an extra object in router.navigate seems less than ideal, especially for direct URL entry in the browser.
This is the structure of my code:
// Sample code goes here
Any suggestions or insights are appreciated. Thank you!