Skip to main content

What it flags

An interpolation, property binding, structural directive or control-flow block ({{ total() }}, [count]="lineCount()", *ngIf="hasDiscount()", @if (expensiveLines().length)) in a component’s inline or templateUrl template calls a method of that component, or reads a getter, whose body loops over a collection. A loop statement, an array method that visits every element (filter, map, reduce, sort, some and similar), or a call to another such member counts. A loop inside a callback the member only defines or returns, such as return () => this.rows.sort(...), does not run when the binding is read and does not count. Neither does a method the body only references, such as return this.calculate;. Angular re-evaluates every binding on each change detection pass, so the loop reruns even when nothing it reads has changed. Event bindings such as (click)="checkout()" run only on their event and are not reported, nor are methods that do no iteration, methods referenced only inside an HTML comment, names a template declares locally, object-literal keys such as active in [ngClass]="{ active: isOn }", and pipe names such as currency in {{ amount | currency }}. The finding sits on the method or getter. In a component with changeDetection: ChangeDetectionStrategy.OnPush, the finding appears with --include-contextual, because the binding reruns only when that component is checked.

How to review or fix

Compute the value once when its inputs change: a computed() signal, a field updated where the data changes (for example in ngOnChanges or after the request that loads it), or a pure pipe. Leave it when the collection always stays small.

Configuration

Set the rule to "off" in loadwise.config.json to drop its findings: