A
A
Alena Khrenovskaya2018-08-14 17:45:35
JavaScript
Alena Khrenovskaya, 2018-08-14 17:45:35

What is the best way to implement search by matAutocomplete and autocomplete fields?

There is an array of objects unloaded from PostgreSQL: (modelModel consists, let's say of id (number) and name(string) ) There is such a field with autocompletion:
массив$: Observable<Array<модельModel>>;

<mat-form-field>
              <input matInput
                     placeholder="Номер модели"
                     formControlName="id"
                     [matAutocomplete]="auto">
              <mat-autocomplete #auto="matAutocomplete">
                <mat-option *ngFor="let массив of массив$ | async"
                            [value]="массив.id">
                  {{ массив.id }}
                </mat-option>
              </mat-autocomplete>
            </mat-form-field>

and there is just
<mat-input-container>
                <input matInput
                     formControlName="name"
                     placeholder="Имя модели"
                     readonly>
            </mat-input-container>

If I follow the example from https://material.angular.io , the search does not work (more precisely, it swears in the ts file that the ModelModel does not have any name).
And you need to do the following:
search by matAutocomplete
and automatically load the associated value in input formControlName="name".
I would be grateful for even the slightest hints and guidance. Or alternatives =)
All names are fictitious and coincidences are random!
PS For errors I apologize, more the end of the working day.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question