如何在点击 angular 4 的浏览器后退按钮时提醒用户?
onpopstate 即使在第一次加载页面时也会被调用
import { PlatformLocation } from '@angular/common';
constructor( private platformLocation: PlatformLocation) {
platformLocation.onPopState(() => {
console.log("onPopState called");
window.alert("your data will be lost");
})
}
Run Code Online (Sandbox Code Playgroud)