Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Equivalent of ValidationSummary in Angular
.NET Forms had a nice ValidationSummary control that displayed all the form control client errors.

In Angular forms, you'll need to make your own component.

First make sure your page is in a form:
<form name="form" #f="ngForm"></form>

In your component, print the errors like such:

<div *ngFor="let c of form.form.controls|keyvalue">
<div *ngFor="let e of c.value.errors|keyvalue">
{{c.key}} is invalid: {{e.key}}
</div>
</div>

If you don't like the error printed, you can customize it by sending c.key and e.key to a function.

For example, use jQuery to print the Title of the form instead of the name.
Or change the error key to a more friendly one ("max exceeded" instead of "max", etc)

Created By: amos 1/11/2024 9:36:04 AM