Angular Router 14: Resolve guard

Yuvaraj S
2 min readDec 22, 2022

--

The resolve guard is a special type of guard that can check for data existence. That means once the router gets the data it allows for navigation.

In the previous blog, we understood about can activate child guard. So now we have control over the child routes of the angular router. Link for the previous blog
Angular Router 13: Can Activate Child Guard

Image representing some data

Usually, we use resolve guard to collect the data from the API and once we get the data we will navigate to the route.

Creating our Resolve Guard

create a service file, we import resolve interface from @angular/router
we use our resolve and our resolve method of our resolve interface returns our data.

I have created a service file, where myPromisse() method returns promise data. The service file code snipped have attached below.

And finally we will attach the resolve guard in our router.module.ts

And that’s it, Now you will be able to avigate to about route after 5 second.

Find the Live working Code Here:
https://stackblitz.com/edit/angular-resolve-guards

Next

Angular Router 15 : Lazy Loading Modules

— — — — — — — — — End Of Lecture — — — — — — —

Check All lessons of Angular Intermediate Lessons

https://medium.com/@yuvayuvaraj720444/angular-intermediate-lessons-acbea2dfc9b

--

--

Yuvaraj S

Passionate Angular Developer. I post programming content regarding, Frontend Development with working example. ie, Angular, Html, CSS, Javascript