@@ -645,27 +645,66 @@ export abstract class AbstractControl {
645645 get ( path : Array < string | number > | string ) : AbstractControl | null { return _find ( this , path , '.' ) ; }
646646
647647 /**
648- * Reports error data for a specific error occurring in this control or in another control.
648+ * @description
649+ * Reports error data for the control with the given path.
649650 *
650- * @param errorCode The error code for which to retrieve data
651- * @param path The path to a control to check. If not supplied, checks for the error in this
652- * control.
651+ * @param errorCode The code of the error to check
652+ * @param path A list of control names that designates how to move from the current control
653+ * to the control that should be queried for errors.
654+ *
655+ * @usageNotes
656+ * For example, for the following `FormGroup`:
653657 *
654- * @returns The error data if the control with the given path has the given error, otherwise null
655- * or undefined.
658+ * ```
659+ * form = new FormGroup({
660+ * address: new FormGroup({ street: new FormControl() })
661+ * });
662+ * ```
663+ *
664+ * The path to the 'street' control from the root form would be 'address' -> 'street'.
665+ *
666+ * It can be provided to this method in one of two formats:
667+ *
668+ * 1. An array of string control names, e.g. `['address', 'street']`
669+ * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
670+ *
671+ * @returns error data for that particular error. If the control or error is not present,
672+ * null is returned.
656673 */
657674 getError ( errorCode : string , path ?: string [ ] ) : any {
658675 const control = path ? this . get ( path ) : this ;
659676 return control && control . errors ? control . errors [ errorCode ] : null ;
660677 }
661678
662679 /**
680+ * @description
663681 * Reports whether the control with the given path has the error specified.
664682 *
665- * @param errorCode The error code for which to retrieve data
666- * @param path The path to a control to check. If not supplied, checks for the error in this
667- * control.
668- * @returns True when the control with the given path has the error, otherwise false.
683+ * @param errorCode The code of the error to check
684+ * @param path A list of control names that designates how to move from the current control
685+ * to the control that should be queried for errors.
686+ *
687+ * @usageNotes
688+ * For example, for the following `FormGroup`:
689+ *
690+ * ```
691+ * form = new FormGroup({
692+ * address: new FormGroup({ street: new FormControl() })
693+ * });
694+ * ```
695+ *
696+ * The path to the 'street' control from the root form would be 'address' -> 'street'.
697+ *
698+ * It can be provided to this method in one of two formats:
699+ *
700+ * 1. An array of string control names, e.g. `['address', 'street']`
701+ * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
702+ *
703+ * If no path is given, this method checks for the error on the current control.
704+ *
705+ * @returns whether the given error is present in the control at the given path.
706+ *
707+ * If the control is not present, false is returned.
669708 */
670709 hasError ( errorCode : string , path ?: string [ ] ) : boolean { return ! ! this . getError ( errorCode , path ) ; }
671710
0 commit comments