Return to site

ANGULAR INTERVIEW QUESTION: What is the role of the <base> tag in an Angular app?

ยท ngInterview,fullstack

Actually, in all Angular app, there is always a <๐›๐š๐ฌ๐ž> tag in the ๐ข๐ง๐๐ž๐ฑ.๐ก๐ญ๐ฆ๐ฅ file, in the project root folder:

Thig tag tells the Angular router how to build the URLs for the browsing,

by saying in which folder is the source code to do right the redirections.

If the folder which contains all your application is "๐š๐ฉ๐ฉ" (which is the default folder by Angular CLI), you can just put the value <๐›๐š๐ฌ๐ž ๐ก๐ซ๐ž๐Ÿ="/">.

In conclusion, the <๐›๐š๐ฌ๐ž> tag enables the Angular router to build URLS related to the project "๐š๐ฉ๐ฉ" folder.