Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Type 'this' is not assignable to type 'Window'

$
0
0

@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

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>