Centralized place for parameters in app


#1

I have created a brand new app. I want to have one place where all my parameters will be (server ip address, time-formats, etc) so I can access them easily from one place. I was wondering what is the best practice for this? Where/How should I store them and where/how can I access them?

Cheers


#2

Ionic 1?

Use constants.

http://twofuckingdevelopers.com/2014/06/angularjs-best-practices-001-constants/


#3

I’m not exactly sure what the best practice is but in my Ionic 2 apps provider’s folder I usually have a config.js file with all these values exported like this:

export let VALUE_ONE = “09:00”;
export let VALUE_TWO = “10:00”;

and then in the component or service that requires them I do this:

import {VALUE_ONE) from ‘./config’;

and then I just reference that value in that component where I need it. As I said, I’m not really sure what absolute best practice is - this certainly works though and allows me to keep these values all in one place.

(I guess the export could be a single object called Constants or something and you have all the values you need inside it - and then you just import that object - but I have created individual values)


#4

Thanks for your suggestion, it looks good to me