Get attribute value from config.xml


#1

Hello community,
As I want to introduce API versioning I would like to set an attribute in config.xml like the existing “version” and then parse it in Ionic:

.config(function ($httpProvider) {
    $httpProvider.defaults.headers.common['api_version'] = 1;
});

Is it possible in a simple way?

Thank you :grin:


#2

Are to trying to access the config.xml file that Cordova uses to generate the native apps? If so, that file is not available to be read once the apps are compiled


#3

Not exactly access it directly from the config.xml, instead I would like to grab that value (maybe at compilation time ?) and then use it in Angular .config()


#4

Then look at creating a Cordova Hook to do this. There are many events that you can hook a custom script into and do this. Look on the Cordova website for more information.


#5

I thought that way, thanks!

Edit:

I’ve just found a solution for anyone interested:


+