I want to trigger a click event even without clicking on the button. So I followed the structure mentioned in the post - angular2 manually firing click event on particular element
However, I am getting an error:
Property 'nativeElement' does not exist on type '() => void'
for which I find no relevant reference in the web.
I want to trigger the showAccurateGraphs() button on clicking on accurateExtract().
My code is -
app.component.html
<button type="button" (click)="accurateExtract()" class="btn btn-
dark">Accurate Extract</button>
<button type="button" #accurateExt (click)="showAccurateGraphs()"
class="btn btn-dark">Show Accurate API Graph</button>
app.component.ts
import { Component, OnInit } from '@angular/core';
import { ViewChild, ElementRef, Renderer } from '@angular/core'
constructor(private renderer:Renderer ) {}
@ViewChild('accurateExt') accurateExt: ElementRef;
accurateExtract(){
let event = new MouseEvent('click', {bubbles: true});
this.renderer.invokeElementMethod(
this.accurateExtract.nativeElement,'dispatchEvent', [event]);
}