javascript - Best Approach for Configuration File for an Angular/RequireJS Application? -


is there commonly accepted best practice maintaining configuration file available on client side (sort of equivalent of appsettings section on server side in asp.net application)?

our application based on angular. our desire externalize environment-specific settings (like remote system urls, etc) code itself, ideally ops person , not developer can modify settings in 1 place.

thanks in advance insight!

i don't think it's idea use config.js file when developing angularjs apps. reason being, break possibility automatic testing.

instead, create "settings" service in specify app specific context. example:

angular.module('settings',[]).factory('settingsservice',function(){     var service={};     // insert settings here    service.serverpath = 'whateverwhatever';    service.imagepath  = 'bla bla bal';     return service;  }); 

then inject settingsservice controllers need access settings.

ofcourse, (which omitted simplicity here), instead create serviceservice empty body, , in application .run() method fetch settings server.

i use simple described way, , maintain settingsservice each deployment type ("development", "test", "production" etc). include right settingsservice in build-script depending on target (i use grunt, use ant also).


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -