Topic: Modal to choose between YES and NO to discard changes in CanDeactivate

birmain pro asked 5 years ago


I'm looking in the documentation for the use of modal windows to rule out changes to a form through a service for CanDeactivate. Is there an MDB service that can be imported and that facilitates the use of a modal window in CanDeactivate?
This is my current code. I use Confirm
import { Injectable } from '@angular/core';
import { CanDeactivate } from '@angular/router';
import { FormComponent } from '../../models/model.configuracion';

@Injectable()
export class CanDeactivateFormGuardService implements CanDeactivate<FormComponent> {
canDeactivate(componet:FormComponent):boolean {

if (componet.hayCambios) {

return confirm('Discard the changes?'); }

return true;
}
}
 

Arkadiusz Idzikowski staff answered 5 years ago


Dear birmain, Unfortunately there are some problems with the built-in service that we need to fix. You would need to create your own service, I described how to do that here: https://mdbootstrap.com/support/angular/calling-modal-in-component-from-another-component/ Regards, Arek

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: 6.2.2
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No