How can I resolve a component with the Resolver Service and at the same time subscribe to URL changes in the component to enable paginating, after the component was rendered.
Please see picture down below:
When using a Resolver e. g. ProductResolver to fetch data for the ProductList component, I need to implement the "resolve" interface in the ProductResolver.
Using ActivatedRouteSnapshot however only allows me to get URL params once. Afterwards the user clicks the paginator to fetch new data, which will never be displayed in the ProductList Component.
The paginator will allow the user these URLS:
- /producs?page=1&limit12
- /producs?page=2&limit12
- /producs?page=3&limit12
- /producs?page=4&limit12
- /producs?page=5&limit12
The Resolver will not be reactive on URL changes. So I need to subscribe again to ActivatedRoute and fetch data again from here!
Is there any solution to this, so I do not need to fetch data from two different place, once from the Resolver and again from the Component to enable paginating!
To recap:
- ProductListComponent fetches Data from a ProductResolver and gets rendered
- User clicks paginator to get data for page=2
- ProductListComponent does not react to changes and therefore can not fetch data from server.
- Adding a ActivatedRoute Subscription does the job
But now I fetch the server 2 times!