Search code examples
javascriptangulartypescriptmat-input

Angular matInput


Angular formcontrol works on different matInput, they have the same formControlName but it does not work on the second one. Why is that it works on the first one and not on the second one ? Any idea ? whats the difference ? they are just the same matInput field right ? Thank you.

why is that it does not work when there is [matAutocomplete]="auto" ? what is the alternative ?

Firstone (this works) - the input contains the question

<input matInput placeholder="Ex. Pizza" formControlName="question">

secondone (this does not load the question)

 <input matInput
              #questionSearch 
              [ngClass]="!hasSelectedQuestion() ? '' : 'hidden'"
              [matAutocomplete]="auto"
              [matChipInputFor]="chipList"
              formControlName="question"
              required
              class="full-width"
            />

Solution

  • I think the probleme is in [matChipInputFor]="chipList", it accepts array element