What is wrong in Angular2 ng-if

I’m really new to angular, I have been through all ng-if questions and cannot seem to find the right answer.

I have this:

<tr *ngFor="#position of positions">                               
<td>
 <div ng-if="position.way == 0">Long</div>
 <div ng-if="position.way == 1">Short</div>
 {{position.way}}
 </td>
</tr>

{{position.way}} is outputting either 1 or 0 as expected and is defined as a string in the model. But the two div’s are both displayed no matter what position.way is.

I have tried wrapping 0 and 1 in quotes, I have tried tripple equality operator, same result.

What am I doing wrong here?

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

The ng-if syntax is wrong. It should be:

<tr *ngFor="let position of positions">                               
<td>
 <div *ngIf="position.way == 0">Long</div>
 <div *ngIf="position.way == 1">Short</div>
 {{position.way}}
 </td>
</tr>