enter image description hereTitle: Preventing unnecessary network requests in Angular tabs
Description:
In my Angular project, when I switch to a specific tab, it makes some network requests that are visible in the Network section of the browser’s DevTools. However, these requests are also being made in other open tabs of my Angular project, even though they are not using those specific requests.
I want to ensure that these requests are only made in the tabs that actually need them. To achieve this, I’ve tried placing the services that make these requests in the ngOnDestroy lifecycle hook, but this hasn’t resolved the issue.
Question:
How can I prevent these unnecessary network requests from being made in other tabs of my Angular project? What strategies or best practices can I use to ensure that requests are only made in the tabs that require them?
What I’ve tried so far:
Placing services in the ngOnDestroy lifecycle hook
Expected outcome:
I expect the network requests to only be made in the tabs that are actively using them, and not in other open tabs of my Angular project.