Return to site
ANGULAR INTERVIEW QUESTION: What is the role of the <base> tag in an Angular app?
Actually, in all Angular app, there is always a <๐๐๐ฌ๐> tag in the ๐ข๐ง๐๐๐ฑ.๐ก๐ญ๐ฆ๐ฅ file, in the project root folder:
<!๐๐๐๐ก๐ฆ๐๐ โ๐ก๐๐> <โ๐ก๐๐ ๐๐๐๐="๐๐"> <โ๐๐๐> <๐๐๐ก๐ ๐โ๐๐๐ ๐๐ก="๐ข๐ก๐-8"> <๐ก๐๐ก๐๐>๐ด๐๐๐ข๐๐๐</๐ก๐๐ก๐๐> <๐๐๐๐ ๐๐๐๐="/"> <๐๐๐ก๐ ๐๐๐๐="๐ฃ๐๐๐ค๐๐๐๐ก" ๐๐๐๐ก๐๐๐ก="๐ค๐๐๐กโ=๐๐๐ฃ๐๐๐-๐ค๐๐๐กโ, ๐๐๐๐ก๐๐๐-๐ ๐๐๐๐=1"> <๐๐๐๐ ๐๐๐="๐๐๐๐" ๐ก๐ฆ๐๐="๐๐๐๐๐/๐ฅ-๐๐๐๐" โ๐๐๐="๐๐๐ฃ๐๐๐๐.๐๐๐"> </โ๐๐๐> <๐๐๐๐ฆ> <๐๐๐-๐๐๐๐ก></๐๐๐-๐๐๐๐ก> </๐๐๐๐ฆ> </โ๐ก๐๐>
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.