模式页面.html
<ion-content>
<ion-button id="trigger-button">Click to open modal</ion-button>
<ion-modal trigger="trigger-button" [swipeToClose]="false" [presentingElement]="routerOutlet.nativeEl">
<ng-template>
<ion-content>
<ion-grid>
<ion-row class="">
<ion-col size="4" class="ion-float-left">
<ion-text color="primary"><h6 class="ion-no-margin fw-400">Cancel</h6></ion-text>
</ion-col>
<ion-col size="4" class="ion-text-center">
<ion-text><h6 class="ion-no-margin fw-500">Card Modal</h6></ion-text>
</ion-col>
<ion-col size="4" class="ion-text-end">
<ion-text color="muted"><h6 class="ion-no-margin fw-400">Done</h6></ion-text>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
</ng-template>
</ion-modal>
</ion-content>
模态.页面.ts
import { Component, OnInit } from '@angular/core';
import { IonRouterOutlet, ModalController } from '@ionic/angular';
@Component({
selector: 'app-modal',
templateUrl: './modal.page.html',
styleUrls: ['./modal.page.scss'],
})
export class ModalPage implements OnInit {
constructor( public routerOutlet: IonRouterOutlet ) { }
ngOnInit() {
}
}
打开模态后点击“Click to open modal”按钮.要关闭模态请点击“cancel”。
如何解除离子V6卡模态?
1条答案
按热度按时间yfwxisqw1#
您需要导入并声明ModalController,然后使用
this.modalCtrl.dismiss()
将其关闭。