Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
ERROR TypeError: no se pueden leer las propiedades de undefined (leyendo 'filtro') usando Autocompletar en Angular

Estoy usando Autocompletar en Angular

 <input type="text" matInput [ngModel]="chatList" [matAutocomplete]="autocopmlete" (focus)="filter('')" (ngModelChange)="filter($event)"> <mat-autocomplete #autocopmlete="matAutocomplete" [displayWith]="displayName"> <mat-option *ngFor="let item of filteredObject" [value]="item" (onSelectionChange)="selectUser(item)"> {{ item.Name }} </mat-option> </mat-autocomplete>

tengo esta función de filtro en mi .ts file

 filter(value = '') { if (typeof value !== 'string' || typeof value === 'undefined') { return; } this.filteredObject = this.chatList.filter( a => ~a.Name.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) ); }

el filtro funciona, pero cuando cargo mi página y me enfoco en el campo de texto de búsqueda, aparece este error:

ERROR TypeError: no se pueden leer las propiedades de undefined (leyendo 'filtro')

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Creo que el problema en chatList, puede agregar una condición para resolver eso:

 filter(value = '') { if (typeof value !== 'string' || typeof value === 'undefined') { return; } this.filteredObject = (this.chatList || []).filter( a => ~a.Name.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) ); }
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda