离子工厂列表开放,关闭事件

时间:2017-07-14 15:11:45

标签: angular typescript ionic2 ionic3

嗨,我希望你能帮助我。

我正在使用离子2,我希望控制离子工厂这是HTML结构:

reserve

我想要知道何时打开和关闭离子工厂列表。

1 个答案:

答案 0 :(得分:1)

似乎Ionic不提供用于收听这些事件的API,但您可以像这样轻松添加:

<ion-fab left bottom> <!-- Bind the click event here -->
  <button (tap)="fabToggled()" ion-fab mini>
    <ion-icon name="add"></ion-icon>
  </button>
  <ion-fab-list side="top">
    <button ion-fab (tap)="changeMap('SATELLITE')">
      <ion-icon name="map"></ion-icon>
      <div class="label-map">Satellite</div>
    </button>
    <button ion-fab (tap)="changeMap('HYBRID')">
      <ion-icon name="map-map"></ion-icon>
      <div class="label-map">Hybrid</div>
    </button>
    <button ion-fab (tap)="changeMap('NONE')">
      <ion-icon name="map-map"> </ion-icon>
      <div class="label-map">None</div>
    </button>
  </ion-fab-list>
</ion-fab>

然后在您的组件代码中添加以下内容:

// It's closed by default
private isOpened: boolean = false;

public fabToggled(): void {
    this.isOpened = !this.isOpened;

    if(this.isOpened) {
        console.log('Opened...');
    } else {
        console.log('Closed...');
    }
}