2017-08-04 10 views
1

ionic2にカスタムダイアログボックスを作成したいとします。私は参考文献ionic docsのチュートリアルをたくさん試しましたが、私は何をしたいのですか?ionicでカスタムダイアログボックスを作成する

ユーザーがアイコンをクリックしたときに表示します。 enter image description here

私は同じことを達成するためにいくつかのアイデアを与えてください。

答えて

1

カスタムクラス名とイオンモーダルを使用することができますので、あなたはポップアップ開くためにのみ、このポップアップ

のCSSを上書き:モーダルで使用

openModal() { 
    let modal = this.modalCtrl.create(CustomPopup,{},{showBackdrop:true, enableBackdropDismiss:true}); 
    modal.present(); 
} 

コンポーネント:

import { Component, Renderer } from '@angular/core'; 
import { ViewController } from 'ionic-angular'; 

@Component({ 
    selector: 'custom-popup', 
    templateUrl: 'custom-popup.html' 
}) 
export class CustomPopup { 

    text: string; 

    constructor(public renderer: Renderer, public viewCtrl: ViewController) { 
    this.renderer.setElementClass(viewCtrl.pageRef().nativeElement, 'custom-popup', true); 

    } 

} 

とfinaly SCSS:

ion-modal.custom-popup ion-backdrop { 
    visibility: visible !important; 
    z-index:0; 
} 
ion-modal.custom-popup .modal-wrapper{ 
    top: 20%; 
    width:60%; 
    height:300px; 
    position:absolute; 
} 
+1

modalCtrlを作成したところでいくつかの問題が発生しています。 –

+0

私は何を達成しましたか?欲しいです 。あなたは私のために救い主です。ありがとうございました –

+0

あなたは大歓迎です! –

0

あなたは以下のようにカスタムコントローラを作成追加することができます -

import { AlertController } from 'ionic-angular'; 

constructor(private alertCtrl: AlertController) { 

} 

presentAlert() { 
    let alert = this.alertCtrl.create({ 
    title: 'Low battery', 
    subTitle: '10% of battery remaining', 
    cssClass: 'my-class', 
    buttons: ['Dismiss'] 
    }); 
    alert.present(); 
} 

<style> 
.my-class{ 
background: gray; 
color:#333; 
} 
</style> 

をあなたのカスタムスタイルを追加することができますと同じように。あなたは完全な例を得ることができます - https://www.tutorialsplane.com/ionic-popup

関連する問題