import { CanDeactivate } from "@angular/router" ; import { Observable } from "rxjs/Rx" ; export interface ComponentCanDeactivate { canDeactivate : ( ) => boolean | Observable < boolean > ; } export class ContactFormGuard implements CanDeactivate < ComponentCanDeactivate > { canDeactivate ( component ) { return component . canDeactivate ? component . canDeactivate ( ) : true ; } }