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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -