Using Angular in SharePoint — always use relative paths
This applies to SharePoint or actually more than SharePoint where perhaps you are building a big site with Angular, where multiple teams are dropping functionality are URLs, except, they don’t know WHAT URL ahead of time
Now before you jump on “lazy loading” — no that is not applicable here. Lazy loading is great, I ❤ it. But it won’t be suitable where the applications are completely independent, and have no idea they are being lazy loaded. I know there are workarounds, and I think they are worth investigating. I’ll leave them for another day.
But lets say the purpose is simple — a webpart written in say SPFx using Angular, and you have no idea what path it will run on. It could be at /sites/test or /sites/prod. Always,
a) Set base href to “.”
b) Load scripts using relative paths such as ../SiteAssets
In the case of SPFx, a very popular approach is to use SharePoint as a CDN. This CDN path has to be a part of your tenancy (unfortunately documentation on this is incorrect where it says that it must originate from .sharepoint.com, no not really! It has to be xxxx.sharepoint.com where xxxx is your tenancy).
So even in that case, you want to use relative paths.
Now using SPFx with Angular, that’s a whole another can of worms, that I am hoping will get resolved in the very near future.