Angular Navigation issue - unable to show / hide menu

15 views
Skip to first unread message

learningA

unread,
Feb 16, 2020, 12:19:18 PM2/16/20
to Angular and AngularJS discussion

Hello,


I’m working on a Angular project/learning and I’m unable to show / hide the navigation bar(menu-top.component) based on login. 

Sample code below i do have the ngif statement evaluated true or false but its not reflecting back to the menu component:



<div *ngIf="isLoggedin"> 
 <nav > 
    <a routerLink="/home" routerLinkActive="active">Home</a> 
    <a routerLink="/contact" routerLinkActive="active">Contact</a> 
    <a routerLink="/about" routerLinkActive="active">About</a>
  </nav>
</div>


Example code setup on stackbliz:  https://stackblitz.com/edit/angular-qmokve


Any help you can provide would be greatly appreciated.
Thanks
R

Dattaram Hodawadekar

unread,
Feb 18, 2020, 4:04:41 AM2/18/20
to ang...@googlegroups.com
isLoggedIn(){ 
      return !!localStorage.getItem('name');
    }

mistake is here, please remove extra exclamation mark

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/3a160f15-c89d-4fd3-94bf-0e5d4001f122%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages