Interview Questions

1. What do you understand about RouterOutlet and RouterLink?

A RouterOutlet is a directive from the router library that acts as a placeholder. It marks the spot in the template where the Router should display the components for that outlet. A router outlet is used as a component.

Syntax:

<router-outlet></router-outlet>  


On the other hand, a RouterLink is a directive on the anchor tags that gives the router control over those elements. Since the navigation paths are fixed, you can assign string values to the router-link directive as below,

Syntax:

<h1>Angular Router</h1>  

<nav>  

  <a routerLink="/todosList" >List of todos</a>  

  <a routerLink="/completed" >Completed todos</a>  

</nav>  

<router-outlet></router-outlet>  

By Md Riyazuddin 2 0
Is this helpful? Yes No

Submit an interview question

Submitted questions and answers are subject to review and editing, and may or may not be selected for posting, at the sole discretion of w3Sniff.

Get Started

Comments

Leave a Comment


Check out more interview questions

Based on your skills

MS SQL Server

97980 1720 4 860

Angular

2788 92 0 46

Wordpress

2157 72 0 36
AD Ad-Free