I have a search component that includes searching by name and by tags for now. I've decided to use a form to validate and create a Search object with the form's value.
The problem is that I have to add a tag to a list each time the user press enter in the tag input but how can I do that in a form way?
<form [formGroup]="searchForm" (ngSubmit)="onSearch()">
<input ... formControlName="name"...>
<input ... placeholder="Enter a tag">
<ul class="tags">
<li *ngFor"...">
</ul>
</form>
EDIT
I am using the form value like this:
this.searchEvent.emit(<Search>this.searchForm.value);
As you can see, only the tag input is attached to the form but not the list
export interface Search {
name?: string
tags: string[]
}
