Property binding uses the following syntax: [someProperty]="an Angular template expression" .
In your case, the template expression is a function (rather than, say, a component property). It's great. But according to the Expression Guidelines section of the Template Syntax manual, expressions should be "idempotent." This means that if
expression returns a string or number; it returns the same string or number when called twice in a string. If the expression returns an object (including Date or Array ), it returns the same object reference when called twice in a string.
Since you did not provide code for your getClass() function, we just assume that it violates the idempotent rule. (You probably return a new array or new object each time.)
In development mode (which is the default mode), change detection is performed twice, and it will break idempotent violations.
To fix this, return the same array or object reference (but you can change the contents of the array or object properties / values). For instance.
export class MyComponent { anArray = []; getClass() {
source share