Define a parameter inconfig.xml so it can be used in app


I am new to ionic and am currently storing “companyId” in app.js e.g.

//Store constants
.constant(‘sysConfig’, {
companyId: ‘5371a51d120b1’,
appVersion: 1.0,

I want to move “companyId” to config.xml and use it in app.js. This will help me make the app more flexible.

How can I do it? Please help


That is not possible nor is it the purpose of the config.xml


Oh. Ok. Thanks.

I have to create two apps for two companies. The icon / splash screen etc. is different for both apps to give a custom look. However internally both apps work in the same way. Data is retrieved from server depending on the company id.

No problem. I will solve my problem it in a different way.

Thanks once again.


Search the forum, I already asked this question and got a good answer using git sub modules.

You could also solve most of these requirements by using a more powerful build process than the basic one provided with ionic starter apps. I use Generator-M-Ionic which is able to change values in your config.xml, generate constants per environment and more.

@leob has a good one too.


The technique I use in my gulp.js file is I can define environment specific values in JSON files which are then written into config.js (by a gulp task).

For instance you can have config-dev.json and config-prod.json, with different values for your ‘companyId’ constant.

This works with the gulp-ng-constant and gulp-extend modules.
Probably not as sophisticated as what Generator-M does but fairly easy to add to your gulp file.


Well while it is possible, it’s not really the intended purpose of the config.xml.
This is for cordova specific features and information. Plugins, webview preferences, icons/splashscreens. Not the actual implementation of your app.

A better option would be to define a const.js file and store all that information in there. This way, you can change that when you need to.