Angular: Prevent route change if any changes made in the view
You can implement canDeactivate using typescript like import { Injectable } from ‘@angular/core’; import { CanDeactivate } from ‘@angular/router’; import { ViewthatyouwantGuard } from ‘./path to your view’; @Injectable() export class ConfirmDeactivateGuard implements CanDeactivate<ViewthatyouwantGuard> { canDeactivate(target: ViewthatyouwantGuard) { if (target.hasChanges) { return window.confirm(‘Do you really want to cancel?’); } return true; } } // hasChanges … Read more