How to prevent modal dismiss when clicked outside the modal in Ionic?

Make use of the enableBackdropDismiss-option when creating the modal (link to docs).

let modal = this.modalCtrl.create(ModalPage, { data: data }, { enableBackdropDismiss: false });

ionic 4

const modal = await this.modalCtrl.create({
  component: ModalPage,
  componentProps: {
    'data': this.data 
  },
  backdropDismiss:false
});

For ionic 4

backdropDismiss:false,

the model should be created like this

 const modal = await this.modalCtrl.create({
      component: SetaddresComponent,
      cssClass: 'my-custom-modal-css',
      componentProps: { },
      showBackdrop:true,
      backdropDismiss:false,
    },