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

168
Vistas
Why Angular Change Detection re-renderes component if data didn't change?

Basically for what I understand, Angular Change Detection will re render component if a change happened, or to be precise a property used in the template has changed. In any other case it will not (unnecessary) re render that component if the value stayed the same.

Here's the example that I've made, button inside the component triggers CD. Call of that button click event is empty so it doesn't update any value inside the component. Only this used in the template is a getter function that always returns the same simple value.

So if CD compared previous and current value there is no change so why would is seem that component re rendered since the console log inside the getter function was called.

Or it has crossed my mind, the console.log inside the getter was called during CD value comparison and the component did not really re-render.

Here's the example https://angular-playground.stackblitz.io.

import { ChangeDetectionStrategy } from '@angular/core/src/change_detection/constants';

@Component({
  selector: 'my-app',
  styleUrls: ['./app.component.scss'],
  templateUrl: './app.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent {

  get lastName() {
    console.log('CD triggered rerender')
    return 'Boodin';
  }

  buttonClick(){
    //does nothing, doesnt set any value!
  }
}
<p>{{lastName}}</p>
<button (click)="buttonClick()">Trigger Change Detection</button>
about 4 years ago · Juan Pablo Isaza
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