Search code examples
javascriptionic-framework

Runtime Error: this.initializationApp is not a function


import {
    Component,
    ViewChild
} from '@angular/core';

import {
    Platform,
    NavController
} from 'ionic-angular';

import {
    StatusBar
} from '@ionic-native/status-bar';

import {
    SplashScreen
} from '@ionic-native/splash-screen';

import {
    Storage
} from '@ionic/Storage';

import {
    HomePage
} from '../pages/home/home';

import {
    LoginPage
} from '../pages/login/login';

import {
    RegisterPage
} from '../pages/register/register';

@Component({
    templateUrl: 'app.html'
}) export class MyApp {
    _platform: Platform;

    public get platform(): Platform {
        return this._platform;
    }

    public set platform(value: Platform) {
        this._platform = value;
    }

    @ViewChild('content') nav: NavController;
    rootPage: any;
    initialization: any;
    initializationApp: any;
    Platform: any;
    statusBar: any;
    splashScreen: any;
    Storage: any;

    constructor(public platform1: Platform, public StatusBar: StatusBar, public SplashScreen: SplashScreen, private storage: Storage) {
        this.initializationApp();
    }

    initializeApp() {
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });

        this.storage.get('session_storage').then((res) => {
            if (res == null) {
                this.rootPage = LoginPage;
            } else {
                this.rootPage = HomePage;
            }
        });
    }
}

Solution

  • In your constructor method, you are calling this.initializationApp();, but the method is actually called initializeApp(). Change the constructor to call this.initializeApp(); and you should be good to go.