<tag-input
id="enter-tags"
name="enter-tags"
[modelAsStrings]="true"
[addOnBlur]="true"
[(ngModel)]="tagModel"
[addOnPaste]="true" [editable]="true">
</tag-input>
<button type="submit"
(click)="PutTagDataToServer()"
[disabled]="!validateForm()">
Submit Tags
</button>
I have a race condition between when an tag gets added to my model onblur, and a put to my server, triggered by clicking a submit Bitton.
If I have a tag sitting in the input field, as in it hasn't been added yet to tagModel
, then I tell my form to submit, I get inconsistent results because the tag gets added to my model asynchronously. Sometimes the put wins the race, some times the tag wins.
I have validation to ensure I have tags, but that still doesn't ensure a tag sitting in the input field, thus not yet appended to tagModel
, will get added before my put occurs.
What is a good way to resolve this?