I have setup AlertJS properly with my Angular App and it is working good for my success,error, and alert. However, the way I setup the confirm method is not working properly.
Here is the implementation for my AlertJS Service
confirm(title: string, message: string, okCallback: () => any, cancelCallback: () => any) {
alertify.confirm(title, message, (e: any) => {
if (e.button.text === 'OK') {
okCallback();
} else {
cancelCallback();
}
});
}
success(message: string) {
alertify.success(message);
}
error(message: string) {
alertify.error(message);
}
warning(message: string) {
alertify.warning(message);
}
message(message: string) {
alertify.message(message);
}
alert(title: string, message: string, movable: boolean) {
alertify.alert(title, message).set('movable', movable);
}
in my component, I am calling the confirm method for the AlertifyJS as the following:
this.alertify.confirm('Success!',
'Secret questions/answers have been saved!, would you like to setup a new password?',
() => {
this.isActive = false;
this.isCreateNewPassword = true;
},
() => {
this.router.navigate(['/registrations']);
});
It is not populating the title correctly. Instead, it is keeping it as default and putting the word 'Success' as my message.
When I remove the title as a parameter from both the implementation and the call then the confirm works as expected!
Any idea how to fix this?
The implementation for the confirm method should be like this
confirm(title: string, message: string, okCallback: () => any, cancelCallback: () => any) {
alertify.confirm(title, message, () => { okCallback(); }
, () => { cancelCallback(); });
}