【发布时间】:2018-04-01 14:20:11
【问题描述】:
我正在尝试调用我在卸载组件之前自己创建的 post 方法,但它不起作用。
我在@HostListener 上设置了一个断点,当我打开另一个组件时它不会在那里中断。
我正在使用 Chrome 进行调试,并为卸载和卸载前打开了事件侦听器断点,当我打开不同的组件时它们会中断。
我的代码中是否缺少某些内容?
import { Component, OnInit, HostListener } from '@angular/core';
Component({
templateUrl: 'new-component.html'
})
export class NewComponent implements OnInit {
@HostListener('window:beforeunload') onBeforeUnload() {
PostCall();
}
}
【问题讨论】:
标签: angular debugging onbeforeunload angular-components