Created
March 21, 2017 16:49
-
-
Save javebratt/ecb8f46c35bf73d4fd93016ba35d1ccd to your computer and use it in GitHub Desktop.
This file contains 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
// You can create a function in your authentication provider that resolves the value of admin: | |
isAsdmin(): Promise<any> { | |
return new Promise( (resolve, reject ) => { | |
firebase.database().ref(`userProfile/${userId}/admin`).once('value', adminSnapshot => { | |
resolve(adminSnapshot.val()); | |
}); | |
}); | |
} | |
// That will return wither tru or false, then you call it from the class: | |
constructor(public navCtrl: NavController, public authData: AuthData) { | |
authData.isAsdmin().then( adminStatus => { | |
this.isAdmin = adminStatus; | |
}); | |
} | |
// Then is just a matter of calling it inside the html: | |
<ion-content padding> | |
<div *ngIf="isAdmin"> | |
<h3>Hey Admin!</h3> | |
<p>What would you like to do?</p> | |
</div> | |
<div *ngIf="!isAdmin"> | |
<h3>Hey Regular User!</h3> | |
<p>What would you like to do?</p> | |
</div> | |
</ion-content> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment