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

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -