I have set up two parameterized routes for handling mails.
{ path: 'mails', component: MailsComponent, canActivate: [AuthGuard] },
{ path: 'mails/:label', component: MailsComponent, canActivate: [AuthGuard] },
{ path: 'mails/folder/:folder', component: MailsComponent, canActivate: [AuthGuard] }
Within the component, I need to access route parameters based on certain conditions.
ngOnInit(): void{
if (this.googleAuth.stateFlag) {
// handle labels
this.route.paramMap.subscribe(route => {
this.label$ = route.get('label');
this.googleAuth.selectedEmailLabel(this.label$);
});
}
else {
// handle folders
this.route.paramMap.subscribe(route => {
this.folder$ = route.get('folder');
console.log('folder handle:', this.folder$);
this.googleAuth.selectedEmailFolder(this.folder$);
});
}
}
Despite the condition being in place, the else block is always executed.