Skip to content

Commit d7dce7c

Browse files
committed
chore(readme): add new docs for hasError(‘*’)
1 parent e67a8aa commit d7dce7c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ You can optionally pass in conditions in which to activate the error.
251251
</div>
252252
```
253253

254+
You can also use the "catch-all" selector to get the state of your entire control's validity, alongside on an optional state collection.
255+
256+
```html
257+
<div>
258+
<div [ngClass]="{
259+
invalid: myError.hasError('*'),
260+
invalidTouchedDirty: myError.hasError('*', ['touched', 'dirty'])
261+
}">
262+
</div>
263+
<input type="text" formControlName="username">
264+
</div>
265+
266+
<div ngxErrors="username" #myError="ngxErrors">
267+
<div ngxError="required" [when]="dirty">
268+
Field is required
269+
</div>
270+
</div>
271+
```
272+
254273
#### hasErrors: boolean;
255274

256275
The `hasErrors` property returns `true` if your control has any number of errors. This can be useful for styling elsewhere in your template on a global control level rather than individual errors.

0 commit comments

Comments
 (0)