0

I'm trying to get the li element to display {{info.email}} USER ON THIS DEVICE only if localStorage variable matches.I need it inside the li element as this data is coming from the database. Can anyone shed some light on how to achieve this ?

<ul>
    <li *ngFor="let info of infos" (click)="personTapped($event, info);" *ngIf="(window.localStorage.getItem('userLoggedIn') === info.email)"> {{info.username}} (USER ON THIS DEVICE) 
    </li>
</ul>
030
  • 10,842
  • 12
  • 78
  • 123
hayonj
  • 1,429
  • 3
  • 21
  • 28
  • Why don't you expose the list of things you actually want to display from the component instance? `*ngFor="let info of infosToShow()"`. – jonrsharpe Dec 08 '16 at 00:13
  • 1
    Dup of http://stackoverflow.com/questions/40860933/ngif-and-ngfor-on-td-td-element http://stackoverflow.com/questions/39570915/using-ngif-and-ngfor-in-option http://stackoverflow.com/questions/34657821/ngif-and-ngfor-on-same-element-causing-error – yurzui Dec 08 '16 at 06:20

1 Answers1

0

As yurzui said, you can do it like this: *ngIf and *ngFor on <td></td> element using the ng-container.

or use [hidden] instead of *ngIf.

Community
  • 1
  • 1
slaesh
  • 16,659
  • 6
  • 50
  • 52