I'm looking at the Ionic Config Service from here: https://ionicframework.com/docs/api/config/Config/
I would like to use the Config functionality to set global configuration variables (in my case API keys). I'm struggling to get it to work however.
Whenever I call:
config.set('ios', 'green', 'light');
It tells me that config is not defined. However I am unable to import Config as
import { Config } from 'ionic-angular';
does not work. I thought it could be imported like the Platform Service but it does not seem like it. The documentation lacks further information.
Any help appreciated.
You have to add the Config
dependency in the constructor
of your component
import {Config } from 'ionic-angular';
constructor(public config:Config){
}
Then, you can access it via
this.config.get('favoriteColor');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With