Return to site

ANGULAR INTERVIEW QUESTION: What is the '<router-outlet>' tag in Angular?

· ngInterview,fullstack

The RouterOutlet is a directive of the Angular router allowing you to dedicate a placeholder in your template.

 

Then, the Angular router displays the components related to the current route in this placeholder.

For example, if the URL is '/dashboard', the router outlet will display the 'DashboardComponent' where the  tag is located.

 

Ex of app.component.html

<𝑎𝑝𝑝-𝑛𝑎𝑣𝑏𝑎𝑟>

<𝑟𝑜𝑢𝑡𝑒𝑟-𝑜𝑢𝑡𝑙𝑒𝑡>

<𝑎𝑝𝑝-𝑓𝑜𝑜𝑡𝑒𝑟>

 

𝐒𝐨 𝐭𝐡𝐞 𝐑𝐨𝐮𝐭𝐞𝐫𝐎𝐮𝐭𝐥𝐞𝐭 𝐢𝐬 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐫𝐨𝐮𝐭𝐢𝐧𝐠 𝐝𝐢𝐫𝐞𝐜𝐭𝐢𝐯𝐞 𝐚𝐥𝐥𝐨𝐰𝐢𝐧𝐠 𝐭𝐨 𝐝𝐲𝐧𝐚𝐦𝐢𝐜𝐚𝐥𝐥𝐲 𝐫𝐞𝐧𝐝𝐞𝐫 𝐚 𝐩𝐚𝐫𝐭 𝐨𝐟 𝐲𝐨𝐮𝐫 𝐭𝐞𝐦𝐩𝐥𝐚𝐭𝐞𝐬, 𝐚𝐜𝐜𝐨𝐫𝐝𝐢𝐧𝐠 𝐭𝐨 𝐭𝐡𝐞 𝐠𝐢𝐯𝐞𝐧 𝐮𝐫𝐥.