2

I am trying to conditionally hide form validation items with the [hidden] attribute. It works but it blinks on page load even though I added model.pristine to the form.

<div class="alert alert-danger" [hidden]="model.valid || model.pristine">
   The model is required.
</div>
Kabb5
  • 3,760
  • 2
  • 33
  • 55
David Sagang
  • 317
  • 1
  • 6
  • 24

1 Answers1

2

Try using the *ngIf structural directive instead of using the [hidden] attribute.

<div class="alert alert-danger" *ngIf="!(model.valid || model.pristine)">
  The model is required.
</div>

You can read more about *ngIf vs. [hidden] here and here.

Kabb5
  • 3,760
  • 2
  • 33
  • 55