concept routerLink in category angular

appears as: routerLink
Angular in Action

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 use routerLink.

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 typically href is the attribute for an anchor tag that gives the browser that information. When you use href 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 use href 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.

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest