Created
June 25, 2018 20:57
-
-
Save haverchuck/c51d864b9d1b67d7b95162e92298d64b to your computer and use it in GitHub Desktop.
ionic-amplify-part-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, AfterContentInit } from '@angular/core'; | |
import { Events } from '@ionic/angular'; | |
import { AuthGuardService } from '../../services/auth-route-guard' | |
@Component({ | |
selector: 'app-page-home', | |
templateUrl: 'home.page.html', | |
styleUrls: ['home.page.scss'] | |
}) | |
export class HomePage implements AfterContentInit{ | |
authState: any; | |
// including AuthGuardService here so that it's available to listen to auth events | |
authService: AuthGuardService | |
constructor(public events: Events, public guard: AuthGuardService) { | |
this.authState = {loggedIn: false}; | |
this.authService = guard; | |
} | |
ngAfterContentInit(){ | |
this.events.publish('data:AuthState', this.authState) | |
} | |
login() { | |
this.authState.loggedIn = true; | |
this.events.publish('data:AuthState', this.authState) | |
} | |
logout() { | |
this.authState.loggedIn = false; | |
this.events.publish('data:AuthState', this.authState) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment