Skip to main content
edited tags
Link
georgeawg
  • 49k
  • 13
  • 77
  • 98
Source Link
user3501613
  • 640
  • 2
  • 13
  • 33

How to inject multiple providers in app.config in Angularjs

I have multiple providers in my project and each provider have its own constructor,I am trying to inject all these providers into main app.config. I tried bellow scenario but its not working

tried to add all providers inside the array itself but its not working

app.config([
'EquityValueProvider', function (EquityValueProvider) {
EquityValueProvider.setAPIURL('https://localhost:44333/api/equityvalue');
},
'HeatMapServiceProvider', function (HeatMapServiceProvider) {
HeatMapServiceProvider.setAPIURL('https://localhost:44333/api/equityvalue');
},
'RetailerProvider', function (RetailerProvider) {
RetailerProvider.setAPIURL('https://localhost:44333/api/equityvalue');
}]);

but the bellow code is working (multiple config)

 app.config([
'EquityValueProvider', function (EquityValueProvider) {
EquityValueProvider.setAPIURL('https://localhost:44333/api/equityvalue');
 }])
.config([
'HeatMapServiceProvider', function (HeatMapServiceProvider) {
HeatMapServiceProvider.setAPIURL('https://localhost:44333/api/equityvalue');
}])
.config([
'RetailerProvider', function (RetailerProvider) {
RetailerProvider.setAPIURL('https://localhost:44333/api/equityvalue');
}]);

But here i am adding multiple config,instead of that can i make a single config and add all the providers.