Should the href attribute still be set with Angular?

Viewed 136

I wonder whether there is a good reason to set (or not to set) the href attribute on internal links in an Angular 7 single-page application.

It works with or without, as Angular uses the routerLink attribute.

2 Answers

Although Angular Router uses routerLink directive, the href attribute is still the only solution for external links, e.g. https://stackoverflow.com.

Using both routerLink and href does not make any sense as long as the latter one gets overwritten by the routerLink.

href will reload the page, where as RouterLink is a directive that just leaves the SPA state as is and brings the Component attached to the route in the router-outlet

I believe there are other subtle advantages like setting the routerLinkActive

Related