@Javiv wrote:
Hello, I need to use the “self = this” trick in the app.component.ts file but it’s giving me a wierd error and I cannot find a solution in Google.
BTW: If I save the file while the android simulator is opened, it “rebuild” and the error disappear. It appears everytime that I use the “ionic cordova run android”:
https://i.imgur.com/l9UHNOv.jpg
I even tried a clean code like:
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen){ self = this; ... }
Any idea? I need it because I want to have the firebase.auth() listener in the app.component.ts:
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { self = this; platform.ready().then(() => { //add listener firebase.auth().onAuthStateChanged(function(user) { if (user) { console.log('IS SIGNED IN -> Home page'); self.rootPage = HomePage; } else { console.log('IS SIGNED OUT -> Login page'); self.rootPage = LoginPage; } });
…
Any idea?
Posts: 6
Participants: 2