AngularJS: Injecting rootScope or service variable in config

85 views Asked by At

I get data from the DB and want to set inside config. Now, I get it inside $http.get in a service and store in a rootScope variable as well. How can I access inside config? I saw some examples, do I need a Provider? Any simple example will help a lot. Thanks!

PS. I m configuring api key for google maps

Update: I have a provider like the following, and I get the API key value in Run and set it in rootScope. Where should I call setKey method?

    function GmapsKeyProvider() {
    var _key = null;
    this.setKey = function(key){
        _key = key;
    };
    this.$get = function (){
      return _key;
    };
}
0

There are 0 answers