The Angular Resolve route guard or Angular Resolvers allow us to load some data before we navigate to a Route. In this lecture you will learn what is Angular Resolve guard and how to use it in a Angular Application.
The Angular renders the Angular Component, when we navigate to a route. The component will then send an HTTP request to back-end server to fetch data so as to display it to the user. We generally do this in ngOnInit Life cycle hook
The Problem with this approach is that, the user will see a empty component for the time the data is not available. The component will show the data after it arrives. The one way to solve this problem is to show some loading indicator to the user for the time the data is being loaded from server
The another way to solve this is to make use the Resolve route guard. The Resolve route guard pre fetches the data before navigating to the route. Hence the component is rendered along with the data. Lets understand resolve route guard with an example.
DOWNLOAD SECTION SOURCE CODE HERE: drive.google.com/file/d/16SYO...
22 мар 2022