当我单击来自特定组件的应用程序的共享头注销按钮时,首先调用注销函数,然后调用组件ngOnDestroy。
如何在调用注销函数之前调用ngOnDestroy。
header.component.ts
logout() {
//CALLING FIRST
}
specific.component.ts
ngOnDestroy(){
//CALLING AFTER LOGOUT
}
header.component.html
<logout button>
<specific.component.html
<header></header>
发布于 2018-04-07 14:35:15
实际上,这是正确的行为,但你可以尝试使用这样的东西:
在父文件中,它包括标头和特定的:
show: boolean = true;
onLogout() {
this.show = false;
}
在header...ts中:
@Output() onLogout: EventEmitter<any> = new EventEmitter<any>();
logout() {
this.onLogout.emit('');
// your logout operations;
}
在parent...html中:
<specific *ngIf="show" ...>
在以这种方式注销操作之前,可能会销毁特定的组件;P.S.没有尝试过这一点,只是建议
https://stackoverflow.com/questions/49712534
复制相似问题