79778352

Date: 2025-09-29 16:36:22
Score: 1
Natty:
Report link

Code Block:

import { Component } from '@angular/core';

@Component({
  selector: 'app-async-demo',
  template: `
    <h1>Counter: {{ counter }}</h1>
    <button (click)="incrementAsync()">Increment Async</button>
  `
})
export class AsyncDemoComponent {
  counter = 0;

  incrementAsync() {
    // Change inside setTimeout
    setTimeout(() => {
      this.counter++; // View may NOT update
      console.log('Counter updated:', this.counter);
    }, 1000);
  }
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Lavi Kumar