Code: Select all
@Component({
//selector and other properties
host: {
'(window:resize)': 'onResize($event)',
'(window:beforeunload)': 'confirmNavigation($event)'
}
})
Code: Select all
<p-confirmDialog class="confirmdialog" header="Confirmation" appendTo="body" icon="fa fa-question-circle" width="425"></p-confirmDialog>
Code: Select all
confirmNavigation(event:any) {
var isEditableMode = this.form.isDirty; // check if the form is dirty
if (isEditableMode == true) {
this.confirmationService.confirm({
message: 'Do you want to leave the page?',
accept: () => {
//Need to allow the current event to continue if the user clicks on 'Yes'
},
reject: () => {
return false; // prevent the current event, return false is not working
}
});
}
}
Can anybody help?