Issue
I want to hide the toolbar .custom-nav-link
div when the ionic side menu will open and again show this when the side menu is closed.
How to detect and apply conditions in HTML based on ion-menu is open or close?
<ion-toolbar>
<div class="containers">
<div class="logo" >
<h4>My Toolbar</h4>
</div>
<div class="custom-nav-link" slot="end">
<nav class="desktop-nav">
<ul class="nav-list">
<li *ngFor="let p of buttonLinks">
<a href="">{{p.title}}</a>
</li>
</ul>
</nav>
</div>
<div class="">
<ion-buttons slot="start">
<ion-menu-button menu="userMenu">
<ion-icon name="apps"></ion-icon>
</ion-menu-button>
</ion-buttons>
</div>
</div>
</ion-toolbar>
Solution
Try this:
import { MenuController } from '@ionic/angular';
public isMenuOpen: boolean = false;
constructor(public menuCtrl:MenuController){}
ngOnInit() { // or on click of menu button
this.menuCtrl.isOpen('userMenu').then(res => {
this.isMenuOpen = res;
})
}
and html
<div *ngIf="!isMenuOpen" class="custom-nav-link" slot="end">
<nav class="desktop-nav">
<ul class="nav-list">
<li *ngFor="let p of buttonLinks">
<a href="">{{p.title}}</a>
</li>
</ul>
</nav>
</div>
<div class="">
<ion-buttons slot="start">
<ion-menu-button menu="userMenu">
<ion-icon name="apps"></ion-icon>
</ion-menu-button>
</ion-buttons>
</div>
Answered By - yatinsingla
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.