0

I was trying to declare a variable as ID of autocomplete. But it throws an error.

<div formArrayName="AddonSection">
  <div [formGroupName]="i" *ngFor="let section of marketForm.get('AddonSection')['controls']; let i = index">
    <mat-form-field>
      <input (keyup)="autocompleteFilter($event.target.value, i)" type="text" matInput formControlName="GroupName" [matAutocomplete]="auto"+"i">
      <mat-autocomplete #auto+i="matAutocomplete">
        <mat-option *ngFor="let group of marketGroups" [value]="group">
          {{ group }}
        </mat-option>
      </mat-autocomplete>
    </mat-form-field>
  </div>
</div>

In this above code, I was looping autocomplete inside formArray. So i tried to concat Array Index with string and gave it as ID:

#auto1="matAutocomplete", #auto2="matAutocomplete"

And

[matAutocomplete]=auto1, [matAutocomplete]=auto2

But I am getting an error, tried with a single quote and {{}} and different options a but no luck. Could someone please tell me how to give variable as ID for Autocomplete?

Jonathan Brizio
  • 1,087
  • 1
  • 14
  • 28
Munna Babu
  • 5,496
  • 6
  • 29
  • 44

0 Answers0