How to access ngFor variable from child component or directive

the answer is ViewContainerRef

when you inject it into your constructor it has so much data in it. the ngFor data is in
this.vc['_view']['context']['$implicit']

directive full example

@Directive({
    selector: 'td'
})
export class AddInvAmountBtnDirective implements  AfterViewInit {

  el:HTMLElement
  constructor(ref:ElementRef, private vcViewContainerRef) {
    this.el = ref.nativeElement
  }

  @HostListener('click', ['$event']) tdClick(evEvent){
    console.log('vc._view.context.$implicit',
         this.vc['_view']['context']['$implicit']);
    ev.stopPropagation()
  }
}

Comments

Popular posts from this blog

CPanel - WHM - change sending email via server to email Relay (email supplier SMTP) (mailgun)

OverTheWire[.com] Bandit Walkthrough - JUST HINT, NO SPOILERS

JS Link Tutorial, Sharepoint 2013