Add documentation to the helpers module.
This commit is contained in:
@@ -63,6 +63,13 @@
|
||||
<code>src/app/_helpers/custom-error-state-matcher.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Custom provider that defines how form controls behave with regards to displaying error messages.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<p class="comment">
|
||||
@@ -72,6 +79,11 @@
|
||||
<code>ErrorStateMatcher</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
@@ -130,14 +142,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="5"
|
||||
class="link-to-prism">src/app/_helpers/custom-error-state-matcher.ts:5</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="18"
|
||||
class="link-to-prism">src/app/_helpers/custom-error-state-matcher.ts:18</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Checks whether an invalid input has been made and an error should be made.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -147,6 +161,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -161,6 +176,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Tracks the value and validation status of an individual form control.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>form</td>
|
||||
@@ -173,6 +194,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Binding of an existing FormGroup to a DOM element.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -184,7 +211,8 @@
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>true - If an invalid input has been made to the form control.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -200,10 +228,22 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {ErrorStateMatcher} from '@angular/material/core';
|
||||
import {FormControl, FormGroupDirective, NgForm} from '@angular/forms';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {FormControl, FormGroupDirective, NgForm} from '@angular/forms';
|
||||
import {ErrorStateMatcher} from '@angular/material/core';
|
||||
|
||||
/**
|
||||
* Custom provider that defines how form controls behave with regards to displaying error messages.
|
||||
*
|
||||
* @implements ErrorStateMatcher
|
||||
*/
|
||||
export class CustomErrorStateMatcher implements ErrorStateMatcher{
|
||||
/**
|
||||
* Checks whether an invalid input has been made and an error should be made.
|
||||
*
|
||||
* @param control - Tracks the value and validation status of an individual form control.
|
||||
* @param form - Binding of an existing FormGroup to a DOM element.
|
||||
* @returns true - If an invalid input has been made to the form control.
|
||||
*/
|
||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
const isSubmitted: boolean = form && form.submitted;
|
||||
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
|
||||
|
||||
Reference in New Issue
Block a user