I am facing an issue while trying to determine whether to show/hide mybutton
. The console keeps throwing an error stating that mybutton is undefined whenever it tries to evaluate mybutton.disabled
.
To troubleshoot, I included a true statement: 1===1
, but the same error persists. What could be causing this? How can I refactor this code so that I can successfully add a condition?
<div [ngSwitch]="item.id">
<ng-template [ngSwitchCase]="id1">
<pv-my-selector (onSaveShow)="onSaveShow(mybutton, $event)"></pv-my-selector>
</ng-template>
</div>
<button *ngIf="1===1" #mybutton mat-button (click)="saveClick(item.id)">Save</button>
onSaveShow(mybutton: any, show: boolean) {
mybutton.disabled = !show; <!-- the error seems to originate here -->
}
saveClick(id: string) {
}