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

229
Vistas
How to show number of result count of ngIf?
<div class="prod-div results" *ngIf="product.name.indexOf(searchProd$ | async |lowercase) !== -1 
                || product.details.indexOf(searchProd$ | async |lowercase) !== -1">

And I want to show this

{{ searchCount() }} search results for "{{ searchProd$ | async }}"

I used this code:

searchCount() {
    let num = document.getElementsByClassName('results');
    console.log (num.length);
    return num.length;
  }

The problem is it does not dynamically update, lets say the results should be 6 for 'a', it shows 0 and only updates to 6 if I click the screen or type another key.

EDIT: I get this error core.js:6486 ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '0'. Current value: '6'

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can simply create a trigger in component.ts

ngAfterViewInit(){

searchCount();

}

or you can use any other life cycle hook.

about 4 years ago · Juan Pablo Isaza 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