I am working on an Ionic web project connected to firebase.
I retrieved data from firestore and use it to determine if the user is an admin or fund manager, but the string comparison function does not work.
Here is my typescript code.
role: string = "";
admin: boolean = false;
fm: boolean = false;
constructor(private authService: AuthService, private router: Router,) { }
ngOnInit() {
this.fname = "";
this.lname = "";
this.nric = "";
this.role = "";
this.admin = false;
this.fm = false;
this.user = this.authService.getCurrentUser();
this.getProfile();
if (this.role = "Admin") {
console.log("Admin")
this.admin = true;
}
else {
if (this.role = "Fund Manager") {
console.log("Fund Manager")
}
}
this.getProfile()
would fill up this.role
. When this.role
is "User"
, Admin becomes true, and I am not sure what is causing the problem.
Could there be any problems with my code?