concept routerLink in category angular

This is an excerpt from Manning's book Angular in Action.
In this use of
routerLink
, it accepts the string with the appropriate path to use. If the path starts with a forward slash, it will treat the URL as an absolute path from the domain. It could also be a relative path without the slash. This is probably the most common way to userouterLink
.We saw
routerLink
in chapter 2, but let’s take a moment and talk about why it exists and what it does. In order to facilitate navigating around, links must know which URL to go to, and typicallyhref
is the attribute for an anchor tag that gives the browser that information. When you usehref
with links, the browser will request a new URL from the server, which isn’t what we want. With Angular,routerLink
is the attribute directive that denotes the expected route to navigate to and allows the Angular router to handle the actual navigation. In short, if you usehref
to link to a page, it will trigger a page load from the server, even if it’s a valid Angular route, and that’s much slower than using the router. This is a primary tenet of client-side routing.