Answer the question
In order to leave comments, you need to log in
How not to render the list if it is empty?
Guys, hello everyone!
there is such a code
<mat-form-field class="example-full-width">
<input type="text" matInput placeholder="serch" [matAutocomplete]="auto" [formControl]="searchStr">
<mat-autocomplete #auto="matAutocomplete" showPanel="false" isOpen="false">
<mat-option (onSelectionChange)="selectedFilm(film)" *ngFor="let film of films.results" [value]="film.title">
<img class="example-option-img" aria-hidden [src]="getUrlImage(film.poster_path)" height="25">
<span>{{film.title}}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
Answer the question
In order to leave comments, you need to log in
showPanel="false" isOpen="false"
will not affect anything, because ngFor will still be rendered. These options only define behavior.
it's all right?
<mat-form-field class="example-full-width">
<input type="text" matInput placeholder="serch" [matAutocomplete]="auto" [formControl]="searchStr">
<mat-autocomplete #auto="matAutocomplete" showPanel="false" isOpen="false" *ngIf="films?.results?.length">
<mat-option (onSelectionChange)="selectedFilm(film)" *ngFor="let film of films.results" [value]="film.title">
<img class="example-option-img" aria-hidden [src]="getUrlImage(film.poster_path)" height="25">
<span>{{film.title}}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question