angular - How can I use ComponentRef to destroy my Component from within? -
i want able destroy component within itself. (not parent since it's dynamically created in multiple areas).
i've read angular's api have componentref object. i've tried including in constructor says needs argument , i'm not sure pass it.
link: https://angular.io/api/core/componentref
how can use componentref in component destroy it?
import { component, componentref, oninit } '@angular/core'; export class mycomponent implements oninit { constructor(private ref: componentref) {} ngoninit() { this.ref.destroy() } }
Comments
Post a Comment