I can programatically click a button element with elementref but if a button were of material button then it doesn't work
@ViewChild('findButton') findButton: ElementRef;
clicked() {
console.log('clicked');
}
ngOnInit() {
this.findButton.nativeElement.click()
}
and in the template,
<div class="example-button-row">
<button #findButton (click)="clicked()" mat-raised-button color="primary">Primary</button>
</div>
The mat-raised-button attribute is creating the issue. Here is the code on stackblitz