Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular如何主动销毁组件 #62

Open
deepthan opened this issue Jun 17, 2020 · 0 comments
Open

angular如何主动销毁组件 #62

deepthan opened this issue Jun 17, 2020 · 0 comments

Comments

@deepthan
Copy link
Owner

使用remove函数,它不会触发组件的生命周期,还得手动调用ngOnDestroy

constructor(private element: ElementRef) {} 

// 你要销毁的时候调用它
triggerDestroy(){
    this.element.nativeElement.remove(); 
    this.ngOnDestroy() 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant