2

I have a form in Angular 2 and this is the code associated with button that submits the form

 <button (mouseover)="showMesageValidation()" class="edm-button" type="submit" [disabled]="!f.valid">confirm</button>

I want to trigger a method that prints fields that are not properly validated, but I read that disabled elements do not fire events. I wonder how to list items that are not valid when mouseover the button?

Zeina
  • 59
  • 6
Walter White
  • 976
  • 4
  • 12
  • 29

1 Answers1

2

Just use an *ngIf with the same condition so that errors are only shown when there are some

<div *ngIf="!f.valid">
 <div *ngFor="let err of errors">{{err}}</div>
</div>
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567