Good day,
I have an issue when trying to use the ngIF
in Angular, specifically, when the values has to be negative...
for example
I have this HTML code
<ul class="nav navbar-nav" *ngIf ="identity">
<li>
<a href="#">
<span class="glyphicon glyphicon-home"></span>
Inicio
</a>
</li>
<li>
<a href="#">
<span class="glyphicon glyphicon-th-list"></span>
Timeline
</a>
</li>
<li>
<a href="#">
<span class="glyphicon glyphicon-user"></span>
User
</a>
</li>
</ul>
Where "identity" stores the user data and a token when logged in and it works fine as screenshot below
however, when I use the ngIf = "!identity"
in the next div so different icons will display at the top right corner when no user has logged in, nothing happens
<ul class="nav navbar-nav navbar-right" *ngIf ="!identity">
<li>
<a [routerLink]="['/login']" [routerLinkActive]="['active']">
<span class="glyphicon glyphicon-log-in"></span>
Login
</a>
</li>
<li>
<a [routerLink]="['/register']" [routerLinkActive]="['active']">
<span class="glyphicon glyphicon-user"></span>
Register
</a>
</li>
</ul>
As you can see here, no user data nor token has been generated but still the icons at the top right corner aren't showing up
I'd already tried to use the ngIf
else statement using the <ng-template #anExample>
and adding the second div in it and add it to the *ngIf ="identity; else anExample"
but still it doesn't work.
Thanks in advance for the help