How to Add Constants and use across Ionic3+ Apps
· One min read
Steps
-
Created a folder constants and create a file app.configs.ts
-
Add below code which needs to be used across app
export const AppConfigs = {
APP_NAME: "InoicTemplate",
APP_VERSION: " 1.0.0",
EMAIL: "nagvbt@gmail.com",
SQLITE_DB_NAME: "ionictemp",
...
}
- To use above AppConfigs values add the below code in the page
import {AppConfigs} from '../../constants'
export class AboutPage {
private appName: string;
private versionNumber: string;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.onInit();
}
onInit() {
this.appName = AppConfigs.APP_NAME;
this.versionNumber = AppConfigs.APP_VERSION;
}
}
FILES:
Refer the code files in Github