I am trying to set up a simple canDeactivate guard in Angular 7, and I have tried code from a number of online tutorials, but they all yield the same error:
"Type 'CanDeactivate' is not generic."
What am I doing wrong? I can't even find this error on any google hits other than another 2 year old unanswered question with same issue.
See code here:
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { CanDeactivate } from '@angular/router/src/utils/preactivation';
export interface CanDeactivateComponent {
canDeactivate: () => Observable<boolean> | boolean;
}
@Injectable()
export class CanDeactivateGuard implements CanDeactivate<CanDeactivateComponent> {
canDeactivate(component) {
return component.canDeactivate ? component.canDeactivate() : true;
}
}