ionic4侧边栏事件

1.引入静态变量---XXX.page.ts

import { MenuController, ActionSheetController, Platform, AlertController  } from '@ionic/angular';

constructor(public http: InterceptorService,
    public storage: Storage,
    public menu: MenuController) { }

2.html

<ion-menu side="end">
  <ion-header translucent>
    <ion-toolbar color="secondary">
      <ion-title>您负责的分组</ion-title>
    </ion-toolbar>
  </ion-header> 

  <ion-content>
    <ion-list *ngFor="let item of groupList">
      <ion-item (click)="groupInfo(item.groupId)" style="font-size:18px;">{{item?.groupName}}</ion-item>
    </ion-list>
  </ion-content>
</ion-menu>
<ion-router-outlet main></ion-router-outlet> 

3.ts

 getData() {
    // 侧边栏显示分组
    const batch = '201811';
    const userId = 'LjhR7NddwRanoKU6bfC9yb';
    const urL = 'physical-web/userGroup/queryByUserId/' + userId + '/' + batch;
    this.http.get(urL).subscribe(
      ref => {
        if (ref.json().code === '0000') {
          this.groupList = ref.json().data;
          this.groupIdList = this.groupList[0].groupId;
          this.studentInfo(this.groupIdList);
          this.passNum(this.groupIdList);
          this.titlenameload(this.groupIdList);
          this.groupList.forEach(
            red => {
              this.groupIdList = red.groupId;
              this.groupArray.push({ groupId: this.groupIdList });
            }
          );
        }
      });
  }

点击某项关闭侧边栏 :
 

 this.menu.close();

4.效果图

 

发布了143 篇原创文章 · 获赞 76 · 访问量 16万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览