How can a JavaScript variable set on a server (via properties file) be injected into an AngularJS/JavaScript app?
I am working with a Java Jersey application that contains client files (js, HTML, CSS, etc.) located in the /src/main/webapp folder. There is a JavaScript variable that I need to set before it is served to the client. For example:
<script type="text/javascript">
var serverHost = "<%serverHost%>";
</script>
Is there a way to substitute the value of "<%serverHost%>" with a dynamic value that will be evaluated at runtime? Ideally, this would be done using properties.
The purpose of this is for the client to make REST calls with full URLs as opposed to relative ones. The application will be accessed through a middleman server, requiring the rest calls to reach the originating host server. The use of a properties file is necessary to ensure the application can function across different environments without modification.
Any suggestions or ideas would be greatly appreciated.
Thank you