Angular2 How to trigger (click) event without clicking

后端 未结 3 542
耶瑟儿~
耶瑟儿~ 2020-12-25 12:12

I want to pass data from HTML to the component so I\'ve created an event like this:

3条回答
  •  独厮守ぢ
    2020-12-25 12:38

    Give it a ViewChild reference :

    월 8회 {{r.value['charge']}}

    In your component :

    @ViewChild('myDiv') myDiv: ElementRef;
    
    triggerFalseClick() {
        let el: HTMLElement = this.myDiv.nativeElement;
        el.click();
    }
    

提交回复
热议问题