Editing existing users
In Chapter 11, Recipes – Reusability, Routing, and Caching, we created a ViewUserComponent
with an editUser
function. We need this functionality later in the chapter when implementing a master/detail view in the system, where a manager can see all users in the system and have the ability to edit them. Before we can enable the editUser
functionality, we need to make sure that the ViewUserComponent
component alongside the ProfileComponent
can load any user given their ID.
Let's start by implementing a resolve guard we can use for both components.
Loading data with resolve guard
A resolve guard is a type of router guard, as mentioned in Chapter 8, Designing 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 of a resolve guard...