Should I always be using <router-link>
over <a>
even if I am linking to something like a social media page outside the app?
routerLink is the attribute provided by angular to navigate to different components without reloading the page. Major difference between both is that href kills the state of the current page where routerLink doesnt lose the state of the page.
RouterLink is a built-in Angular Directive that lets you link to specific routes in your app. In the SPA(single-page application), you change what the user sees by showing or hiding portions of the display that correspond to particular components, rather than going out to the server to get a new page.
So in a nutshell, the Link component is responsible for the transition from state to state (page to page), while the Route component is responsible to act as a switch to display certain components based on route state.
The Link component renders a component that can navigate to a screen on press. This renders an <a> tag when using on the Web and It uses a Text component on other platforms.
<router-link>
is intended for in-app links (e.g., to a page within your app). Use <a>
for external links.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With