Angular 2- using *ngIf with multiple conditions

前端 未结 3 1534
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 16:12

I\'m unable to selectively display links on my nav-bar. Based on who logs in (user or admin), I want to change which link shows on my nav-bar.

Below is the code for on

3条回答
  •  借酒劲吻你
    2021-02-18 16:49

    You can move these multiline conditions and complex conditions to your component method as below

    showLogout(){
        if(this.authService.userLoggedIn()== true && this.authService.adminLoggedIn() == false)
            return true;
        else
            return false;
    }
    

    Also, as the angular4 has *ngIf and else you can use it as

     
    Logout
  • Logout

提交回复
热议问题