diff --git a/README.md b/README.md index 207e577..ce41156 100755 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ The `getError` method returns the object associated with your error. This can be > The error returned is identical to Angular's FormControl API -#### hasError(name: string): boolean; +#### hasError(name: string, conditions?: string | string[]): boolean; The `hasError` method informs you if your control has the given error. This can be useful for styling elsewhere in your template based off the control's error state. @@ -235,6 +235,22 @@ The `hasError` method informs you if your control has the given error. This can ``` +You can optionally pass in conditions in which to activate the error. + +> Example: Adds `class="required"` when "myError" has the `required` error _and_ the states are `'dirty'` and `'touched'`. + +```html +
+ +
+ +
+
+ Field is required +
+
+``` + #### hasErrors: boolean; 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.