Topic: updating modal [config] on runtime

itay pro asked 5 years ago


In some cases, a user should be able to close a general purpose modal on escape keyboard click or backdrop click and sometimes he should not

Since the modal is created on app start and displayed later on demand, [config] attribute is changed between

{ ignoreBackdropClick: true, keyboard: false }

or

{ ignoreBackdropClick: false, keyboard: true }

However, the behaviour is always as set on modal creation, thus I it cannot be changed on runtime, on demand

How can I force the new [config] settings ?


itay pro commented 5 years ago

https://mdbootstrap.com/docs/angular/modals/basic/#remove-backdrop


itay pro answered 5 years ago


Excellent ! ................


Arkadiusz Idzikowski staff answered 5 years ago


You need to overwrite the config object completely in order to trigger Angular change detection. For example:

config = { backdrop: false, ignoreBackdropClick: true, keyboard: false };

updateConfig() {
    const updatedConfig = { backdrop: true, ignoreBackdropClick: false, keyboard: true };
    this.config = { ...updatedConfig };
}

Please note that the backdrop won't be updated dynamically in this case (we will take a closer look at that, but I'm not sure if it should work this way). The ignoreBackdropClick and keyboard options should be updated correctly.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 8.6.0
  • Device: NA
  • Browser: NA
  • OS: NA
  • Provided sample code: Yes
  • Provided link: No
Tags