0

Is It possible to insert options dinamically from promise (ex. $http.get(...)) in to

.config(function(uiGmapGoogleMapApiProvider) {
    uiGmapGoogleMapApiProvider.configure(<object from $http>);
})

of angular-ui angular-google-maps directives? If not could you suggest any alternative methods?

Thanks Regards

1 Answers1

1

Nope, a service like $http can not be injected into the provider configuration section. Instead you could consider the following solution:

  • load configuration data
  • once the data is loaded, configure Goolgle Maps loader via uiGmapGoogleMapApi provider
  • manually bootstrap the application

Example

angular.element(document).ready(function () {
  $.getJSON('settings.json')
    .then(function (configData) {
      angular.module('myApp')
      .config(['uiGmapGoogleMapApiProvider', function (uiGmapGoogleMapApiProvider) {
        uiGmapGoogleMapApiProvider.configure(configData);
       }]);
      angular.bootstrap('#myApp', ['myApp']);
    });
});

Demo: plunker

Vadim Gremyachev
  • 57,952
  • 20
  • 129
  • 193