Loading Server-Side Properties on Angular Startup

Sometimes you will need server-side properties (not exposed to the web) in your client-side angular app. A couple examples would be Stripe (payment service) key’s and Google ReCaptcha keys. These keys are normally saved in a properties file because they are different for each environment. To load them on startup (or refresh) in your angular app, do the following:


* Initialization of the APP, and refreshing...
app.run(function ($rootScope, $state, $http) {

// Do an initial instance/session check here
$http.get('properties').then(function successCallback(response) {
        $rootScope.properties = response.data;
    }, function errorCallback(response, exception) {

The call to http://localhost:8080/properties should be a REST call that returns a JSON object of your properties.