Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!