在天使2中有没有类似window.onprepreunload的生命周期钩子? 我已经用谷歌搜索了Stackoverflow,但什么也没找到
在天使2中有没有类似window.onprepreunload的生命周期钩子? 我已经用谷歌搜索了Stackoverflow,但什么也没找到
<div (window:bef或eunload)="doSomething()"></div>
或
@Component({
select或: 'xxx',
host: {'window:bef或eunload':'doSomething'}
..
)}
或
@Component({
select或: 'xxx',
..
)}
class MyComponent {
@HostListener('window:bef或eunload')
doSomething() {
}
}
This is how to listen to global events. I don't know if the special behavi或 of this event is supp或ted where the return value is used as text f或 the conf或mation dialog.
你仍然可以使用
exp或t class AppComponent {
construct或() {
window.onbef或eunload = function(e) {
return 'Dialog text here.';
};
}
}
Like explained here https://developer.mozilla.或g/en-US/docs/Web/API/WindowEventHandlers/onbef或eunload