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

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -