简体   繁体   中英

Ionic 3 side menu close on button click

I am showing some categories in side menu which is working fine . but i need when i click on category then the category show . and it also work fine . but the problem is when i click on category it shows the category but closes the menu . (so if i need to see the category im opening the sidemenu again . i dont want to close the side menu ) .

  <div class="list-item-divider" (click)="onButtonClick()">
     <ion-item-divider tappable menuClose (click)="shop()">
      <ion-icon item-left ios="ios-home" md="md-home">
      </ion-icon>
      <strong>{{"Categories" | translate}}
      </strong>
    </ion-item-divider>
  </div>        

 <div *ngIf="buttonClicked" >
  <div *ngIf="service.categories" class="category-name">
    <ion-item tappable full menuClose *ngFor="let item of 
       service.mainCategories" (click)="getCategory(item.id, item.slug, 
        item.name)">
      <ion-icon item-right class="ion-ios-arrow-forward item-icon">
      </ion-icon>
      <span [innerHTML]="item.name"></span>     
    </ion-item>
  </div>
</div>

.ts

   public buttonClicked: boolean = false;

     public onButtonClick() {
      this.buttonClicked = !this.buttonClicked;
    }

if i understand correctly, you do not need to close sidemenu when you tap on any of the links within

then you need to remove the menuClose there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM