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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -