You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `isValid` method informs you if a your control is valid, or a property is valid. This can be useful for styling elsewhere in your template based off the control's validity state.
276
+
277
+
> Example: Adds `class="valid"` when "myError" has no `required` error.
278
+
279
+
```html
280
+
<div[class.valid]="myError.isValid('required')">
281
+
<inputtype="text"formControlName="username">
282
+
</div>
283
+
284
+
<divngxErrors="username"#myError="ngxErrors">
285
+
<divngxError="required"[when]="dirty">
286
+
Field is required
287
+
</div>
288
+
</div>
289
+
```
290
+
291
+
You can optionally pass in conditions in which to evaluate alongside the property you're checking is valid.
292
+
293
+
> Example: Adds `class="valid"` when "myError" has no `required` error _and_ the states are `'dirty'` and `'touched'`.
You can also use the "catch-all" selector to check if the control is valid, with no specific error properties, alongside on an optional state collection.
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.
276
329
277
-
> Example: Adds `class="hasErrors"` when "myError" has any errors.
330
+
> Example: Adds `class="errors"` when "myError" has any errors.
0 commit comments