Dynamic provider settings through AngularJS application configuration

I have provider modules that accept configurations such as:

angular.module('app', ['search']). config(['$searchProvider', function($searchProvider) { $searchProvider.options({ resultLimit:50, defaultSort:'highToLow' }); }]); 

A new instance of the application will be created for each client - so I’m thinking about using a self-service customer portal to configure the meta object.

This means that now the provider modules must sit inside the callback method to wait for meta before they can set the appropriate configurations.

But let everyone remember: Configuration blocks - are executed during the registration and configuration of the provider. Only suppliers and constants can be entered into configuration blocks. This is to prevent services from being accidentally created before they are fully configured ...

... So, the documents say that you can use the provider in the configuration blocks, but I'm not sure that you can use them to make office calls. Since I have no idea how to do it right, I will show you my "high level" idea:

Terminate dependent providers with another provider callback:

 angular.module('app', ['search','meta']). config(['$searchProvider','$metaProvider', function($searchProvider, $metaProvider) { $metaProvider.get(function(meta){ $searchProvider.options(meta); }); }]); 

What is the best way to handle this?

+4
javascript angularjs
Jul 09 '13 at 19:59 on
source share
1 answer

I have had the same issue recently. I could not find a solution to work within the framework, so I worked on the problem by manually downloading angular after I downloaded all the client configuration information. http://docs.angularjs.org/api/angular.bootstrap

 $.get('/api/context', function () { // ... angular.bootstrap($('#container'), ['app']); }); 
+3
Jul 18 '13 at 9:17
source share



All Articles