Linking Between Components

Let's see how to link different components of the Angular application and how we can use it to display a list of saved photos in our photo gallery project.

Linking components

Now that the application has several components to handle, we need some way of linking between them. To do this, we use the routerLink directive, which allows us to use regular <a> tags like usual, but also hooks in all the niceties from the router.

Much like the href attribute, we pass the route we want to link to:

<a routerLink="edit/{{photo.id}}">Edit</a>

Get hands-on with 1200+ tech skills courses.