I have two string arrays on my backend that I have to fill with either a single string or multiple strings. However they are not key value pairs. I am trying to push a string into one of the arrays but an running into the fact that I do not and cannot specify a control: value pair.
my formArray looks like
collections: new FormArray([]),
my html to select the strings
<md-select placeholder="Collection">
<md-option (click)="addCollectionId('one')" value="Local">Local</md-option>
<md-option (click)="addCollectionId('two')" value="Music">Music</md-option>
<md-option (click)="addCollectionId('three')" value="Performing Arts">Performing Arts</md-option>
<md-option (click)="addCollectionId('four')" value="Sports">Sports</md-option>
<md-option (click)="addCollectionId('five')" value="Restaurants">Restaurants</md-option>
</md-select>
and my logic to add the strings to the formArray looks like:
addCollectionId(id: string) {
const control = <FormArray>this.createCardForm.controls['collections'];
control.push(id);
}
I am getting the error 'Argument of type 'string' is not assignable to parameter of type 'AbstractControl'.
Since I cannot push a control: value pair and only string/strings how can I push strings to the array while still staying in my overall form?
Any help/tips/suggestions would be much appreciated.