Skip to content Skip to sidebar Skip to footer

How Can I Dynamically Create A Modal With A Specific Class In Ionic 2?

Hi I have been stuck with a problem for days now, and so far no research has proved sufficient. I am trying to create a simple modal in Ionic 2 with a specific class (or id). I ne

Solution 1:

You can now pass a CSS class name as an optional parameter when creating the modal.

presentProfileModal() {
    let profileModal = this.modalCtrl.create(Profile, { 
      randomData: randomData }, {
      cssClass: 'myDifficultToAddClass'
    });
    profileModal.present();
  }

Find the official documentation here

Solution 2:

You can try to add a selector to your component

@Component({
    templateUrl: 'modal.html',
    selector:'somemodal',
})

And now you can set all your css on the element somemodal

somemodal {
    // dostuff
}

Post a Comment for "How Can I Dynamically Create A Modal With A Specific Class In Ionic 2?"