Resolve guard

A resolve guard is a type of a router guard, as mentioned in Chapter 9, Design Authentication and Authorization. A resolve guard can load necessary data for a component by reading record IDs from route parameters, asynchronously load the data and have it ready by the time the component activates and initializes.

The major advantages for a resolve guard includes reusability of loading logic, reduction of boilerplate code, and also shedding dependencies, because the component can receive the data it needs without having to import any service:

  1. Create a new user.resolve.ts class under user/user:
src/app/user/user/user.resolve.tsimport { Injectable } from '@angular/core'import { Resolve, ActivatedRouteSnapshot } from '@angular/router' ...

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.