import { fromEvent, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
private unsubscriber : Subject<void> = new Subject<void>();
ngOnInit(): void {
history.pushState(null, '');
fromEvent(window, 'popstate').pipe(
takeUntil(this.unsubscriber)
).subscribe((_) => {
history.pushState(null, '');
this.showErrorModal(`You can't make changes or go back at this time.`);
});
}
ngOnDestroy(): void {
this.unsubscriber.next();
this.unsubscriber.complete();
}
Disabling browser back navigation in Angular
最新推荐文章于 2024-10-09 11:13:12 发布