【发布时间】:2017-08-27 13:20:22
【问题描述】:
我正在使用 Ionic2,我想将模态设置为页面的中心,当单击打开模态时,我希望其他页面不透明度为 0.7,当单击模态关闭的任何位置时,这是我的 Html 代码:
<ion-header>
<ion-navbar color="dark">
<button ion-button icon-only menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Product</ion-title>
<ion-buttons end mode="md" (click)="sharePost()">
<button ion-button icon-only no-padding no-margin>
<ion-icon name="md-share"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content id="body" (click)="closeModal()">
</ion-content>
.ts
import { ReviewPage } from '../review/review';
import { DescriptionPage } from '../description/description';
import { Component, ViewChild } from '@angular/core';
import { ModalController, NavController, NavParams, PopoverController,
ViewController } from 'ionic-angular';
import { ShareOptionsPage } from '../share-options/share-options';
@Component({
selector: 'page-product',
templateUrl: 'product.html',
})
export class ProductPage {
contactModal;
firstViewCtrl;
constructor(public modalCtrl: ModalController,public navCtrl:
NavController, public navParams: NavParams,public popoverCtrl:
PopoverController,public viewCtr:ViewController) {
}
sharePost() {
this.contactModal = this.modalCtrl.create(ShareOptionsPage,
{showBackdrop: true, enableBackdropDismiss: true});
this.contactModal.present();
this.firstViewCtrl = this.navCtrl.first();
}
closeModal() {
if(this.contactModal != null) {
this.firstViewCtrl.dismiss()
}
}
}
但它不起作用,我该怎么办?
【问题讨论】: