Closed
Description
@Component({
template: `
count: {{ count }}
<button (click)="increment()">Increment</button>
`
})
export class Counter {
elementRef = inject(ElementRef)
count = 0
increment() {
this.count++
this.count++
this.count++
expect(elementRef.nativeElement).toHaveTextContent("count: 0")
}
}
await render(Counter)
fireEvent.click(screen.getByText("Increment"))
Expected result: count: 0
Actual result: count: 3
This is not correct Angular behavior and breaks custom change detection strategies.
Proposal: Use ComponentRef#setInput
to change component properties instead.
Metadata
Metadata
Assignees
Labels
No labels