I've a bunch of textareas being generated by a loop, and while I can set the initial values to null, if a user types text then deletes it, the value reverts back to an empty string.
My html:
<form #reviewForm="ngForm" (ngSubmit)="onReviewFormSubmit(reviewForm.value)">
...
<textarea (input)="value = $event.target.value"
[name]="comments" [ngModel]="defaultValue"
id="{{'comments-'+i}}"
placeholder="Comments"></textarea>
...
</form>
My component:
defaultValue: string = null;
The json object requires either a string value for the comments or else null. I set it to null initially with defaultValue, when a user types I get a string value, but once they empty out the textarea it reverts back to "".
How would I go about setting the empty string state to null?