ionic2 configuration from a file in the App Decorator

Hi all, App decorator has a config parameter where the app will have the configuration. Is there a way we can put the configuration in a file and give the file in the App decorator. Also how do we get the app from any page other than app.js

Thanks

1 Like

In a configuration file myConfig.ts

export let data = {
    "option1" : "option1 value"
}

In app.ts

import 'es6-shim';
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import *  as MyConfig from './myConfig'


@App({
  template: '<ion-nav [root]="rootPage"></ion-nav>',
  config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
export class MyApp {
  rootPage: any = TabsPage;

  constructor(platform: Platform) {
    
    console.log(MyConfig.data)
    
  }
}
3 Likes

Really helpful solution, @aaronksaunders, thanks for the solution.