import { Component, OnInit } from '@angular/core'; import {UserContextService} from '../services/user-context.service'; @Component({ selector: 'app-logout', templateUrl: './logout.component.html', styleUrls: ['./logout.component.scss'] }) export class LogoutComponent implements OnInit { constructor(public userContextService: UserContextService) { } // At first glance this might seem like a roundabout way of calling this function but bear with me for a moment. // Introducing the logout mechanism in the router framework ensures that the act of logging out is now also covered by tbe "DirtyGuard" framework // prompting the user before logging out if theres unsaved data in any of the components. ngOnInit(): void { this.userContextService.logout(); } }