Search⌘ K

Linking Between Components

Explore how to link Angular components using the routerLink directive for effective navigation. Understand fetching and displaying saved photos through observables while avoiding issues with Angular’s change detection cycle.

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>

routerLink and anchor tags

The routerLink directive is not limited to just anchor tags, it can be attached to ...