I have my web application deployed to tomcat with an applicatio context. For example my URL looks something like this.
http://localhost:8080/myapp
What I have done is declared a variable in the main jsp file. Then that variable will be available throughout the angular application.
This code should be written in header before including other JavaScript libraries.