Angular - Conditional Formatting in for loop

Solution 1:

First in your HTML, remove this. in HTML there is no need to write that.

For example:

HTML

<div *ngFor="let i of getCode()" [ngStyle]="{'color': i==getLineSelected() ? 'aqua' : 'black' }">
  {{i}}
  <br>
</div>

TS

 getCode() {
   return [1, 2, 3, 4, 5];
 }

 getLineSelected() {
   return 1;
 }

You can play with my code here.