RouterLink

When a user lands on the PageNotFoundComponent, we would like them to be redirected to the HomeComponent using the RouterLink direction:

  1. Implement an inline template to link back to home using routerLink:
src/app/page-not-found/page-not-found.component.ts
...
template: `
<p>
This page doesn't exist. Go back to <a routerLink="/home">home</a>.
</p>
`,
...
This navigation can also be done via an <a href> tag implementation; however, in more dynamic and complicated navigation scenarios, you will lose features such as automatic active link tracking or dynamic link generation.

The Angular bootstrap process will ensure that AppComponent is inside the <app-root> element in your index.html. However, we must manually define where we would like HomeComponent to render, to finalize the router configuration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181