5

i want to change the name displayed on the iteration using ngIf, i am trying to do something like this:

*ngIf="detail.name=='dieselG_d'? detail.name='Diesel Green':Diesel Red

and the console recorded the following error:

Uncaught Error: Template parse errors:
Dale K
  • 25,246
  • 15
  • 42
  • 71
Ali
  • 1,633
  • 7
  • 35
  • 58

1 Answers1

9

I think you're using the wrong directive here- *ngIf is moreso to check if we should display the content at all, not to make an assignment and change a a variable. It requires a statement that evaluates a true or false, and cannot do assignments.

Something like the following might work better for you, if your goal is to display a certain name, rather than to hide content with certain values.

<div> {{ detail.name === 'dieselG_d' ? 'Diesel Green' : 'Diesel Red' }} </div>
Amethystx87
  • 488
  • 3
  • 6