The child component e-notes-p-quick-phrases-list has a mat-grid-list that when the user clicks on, can then click an Insert button that inserts that text into the textarea "notes" in the parent component.
However, even though it successfully Inserts it, the form is still considered invalid since the user has not typed in the textarea.
How can I get the form to detect that text was inserted into the textarea and change the validator to be true?
I cant seem to find anything about this when I search.
HTML (parent):
<form [formGroup]="form" (ngSubmit)="save({ methodName: 'setV', visit: $event })">
<mat-form-field class="bordered">
<textarea matInput formControlName="notes" value="{{visit.ENotes}}"
placeholder="E Notes" rows="5" id="DropHere"></textarea>
</mat-form-field>
<div>
<e-notes-p-quick-phrases-list [vId]='this.vId' (newItemEvent)="addItem($event)"></e-notes-p-quick-phrases-list>
</div>
</form>
TS (parent):
createForm() {
this.form = this.fb.group({
'pD': [this.selectPValue, Validators.compose([Validators.required, ValidatorsLibrary.autocompleteSelect(this.issues)])],
'sD': [this.selectSValue, AutocompleteValidator.selectNotRequired(this.issues)],
'notes': [this.v.ENotes, Validators.compose([Validators.required])],
});
this.onPageLoad();
}
I also tried adding an on-focus to the textarea but it is not getting triggered:
HTML:
<textarea matInput formControlName="notes" value="{{v.ENotes}}"
placeholder="E Notes" rows="5" id="DropHere" on-focus="onChanges()"></textarea>
TS:
onChanges() {
this.form.get('notes').valueChanges
.subscribe(pd => {
this.form.get('notes').markAsTouched;
});
}