Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution environment specific config #21

Open
polster opened this issue Sep 15, 2015 · 0 comments
Open

Execution environment specific config #21

polster opened this issue Sep 15, 2015 · 0 comments

Comments

@polster
Copy link

polster commented Sep 15, 2015

Hi everybody,

Spending some hours without finding a working solution I tried to load the js-url, tracker-url and site-id configuration from my REST API during custom Angular bootstrapping, then make it available to my modules via the $scope in order to be able to pass them to the ngp-piwik directive within the html...

The idea behind: Being able to have different js-url, tracker-url and site-id per environment.

Example:

    <pre>{{environmentConfig[0].value}}</pre>

    <ngp-piwik ngp-set-js-url="{{environmentConfig[1].value}}"
           ngp-set-tracker-url="{{environmentConfig[2].value}}" ngp-set-site-id="{{environmentConfig[3].value}}"></ngp-piwik>

More in detail I am using a deferred bootstrapper:

    /**
     * The deferred boot strapper loading config from the back-end before bootstrapping
     * the app.
     */
    window.deferredBootstrapper.bootstrap({
        element: window.document.body,
        module: 'myApp',
        resolve: {
            environmentConfig: ['$http', function ($http) {
                return $http.get('/rest/skin/environmentConfig');
            }]
        },
        onError: function (error) {
            console.error("Failed to bootstrap, error: " + error)
        }
    });

And while doing the following I can also see in the console output that the JSON config has been loaded successfully:

    angular.module('bepraxis')
        .config(function (environmentConfig) {
            console.log('APP_CONFIG is: ' + JSON.stringify(environmentConfig));
        })

The problem I am running into is the asynchronous part during boot strapping or lets say the config is not available at the moment when the ngp-piwik directive is being injected...

So my question: Has anyone out in the wild faced a similar situation where the analytics server url and site ID could not be hard coded but instead per environment configuration was required?

Thanks a lot in advance for your valuable support.

Best,
Simon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant