import {Component, OnInit} from '@angular/core'; import {Router} from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { constructor(private router: Router) { } ngOnInit(): void { if (sessionStorage.getItem('username')) { if (sessionStorage.getItem('lecturer') === 'true') { this.router.navigate(['ldashboard']); } else { this.router.navigate(['sdashboard']); } } else { this.router.navigate(['']); } } }