docs(config): fix demo for config page not updating. #9413 (#9418)

This commit is contained in:
Nick
2017-01-19 11:24:27 -05:00
committed by Brandy Carney
parent c8c90572bc
commit 4f7de63b9a

View File

@@ -1,5 +1,5 @@
import { Component, NgModule } from '@angular/core';
import { IonicApp, IonicModule, Platform, NavController } from '../../ionic-angular';
import { Config, IonicApp, IonicModule, Platform, NavController } from '../../ionic-angular';
if (!window.localStorage) {
Object.defineProperty(window, 'localStorage', new (function () {
@@ -86,34 +86,11 @@ export class TabPage {
export class ApiDemoPage {
config: any;
initialConfig: any;
constructor(public platform: Platform, public navCtrl: NavController) {
if (window.localStorage.getItem('configDemo') !== null) {
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
} else if (platform.is('ios')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'bottom'
};
} else if (platform.is('windows')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'top'
};
} else {
this.config = {
'backButtonIcon': 'md-arrow-back',
'iconMode': 'md',
'tabsPlacement': 'bottom'
};
}
this.initialConfig = JSON.parse(JSON.stringify(this.config));
constructor(_config: Config, public navCtrl: NavController) {
this.config = _config.settings();
}
load() {
window.localStorage.setItem('configDemo', JSON.stringify(this.config));
window.location.reload();
@@ -140,7 +117,36 @@ export class PushPage {
template: '<ion-nav [root]="root" #content></ion-nav>'
})
export class ApiDemoApp {
config: any;
root = TabPage;
constructor(public _config: Config, public platform: Platform) {
if (window.localStorage.getItem('configDemo') !== null) {
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
} else if (platform.is('ios')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'bottom'
};
} else if (platform.is('windows')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'top'
};
} else {
this.config = {
'backButtonIcon': 'md-arrow-back',
'iconMode': 'md',
'tabsPlacement': 'bottom'
};
}
this._config.set('tabsPlacement', this.config.tabsPlacement);
this._config.set('iconMode', this.config.iconMode);
this._config.set('backButtonIcon', this.config.backButtonIcon);
}
}