In the latest versions of Angular, I was using the following HTML:
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
<mat-option *ngFor="let entity of entityNames" [value]="entity.EntityId">
{{ entity.EntityName }}
</mat-option>
Inside my regular angular component the displayFn
method appears like this:
displayFn(entityId: number): string {
const name = (entityId && entityId > 0) ? this.entityNames?.find(entityName => entityName.EntityId === entityId).EntityName : '';
return name;
}
The problem is, my component "this." is not available and any access to its members fails.