Angular Change Detection and array.includes

40 views Asked by At

Will this line be evaluated every time change detection runs even though the input is a hard-coded set of strings?

*ngSwitchCase="['abc', '123'].includes(item.field) ? "'test'" : ''"
1

There are 1 answers

1
Henrik Bøgelund Lavstsen On

Short answer: Yes

Here is the source of the ngSwitchCase showing it doOnCheck hook checks if value is true.

https://github.com/angular/angular/blob/47ab069070c043c54c46f8ef9b37b14a25857939/packages/common/src/directives/ng_switch.ts#L230