Reputation: 3
I use ngBootbox from eriktufvesson in my AngularJS app and as stated in BootBox.js Documentation how to use callback function in alert:
bootbox.alert({
message: "This is an alert with a callback!",
callback: function () {
console.log('This was logged in the callback!');
}
})
This is my code:
$ngBootbox.alert({
size: "small",
title: "Error",
message: message,
backdrop: true,
closeButton: false,
callback: function () {
//do something when modal closed right?
console.log('hello');
//it's not working right now!
}
});
So, how to make the ngBootBox alert callback function working in AngularJS app?
Please give me enlightenment.
*note: I also use ngBootBox confirm and it's working wonderfully, I just don't know how to deal with the ngBootbox Alert Callback Function.
Upvotes: 0
Views: 690
Reputation: 22323
The documentation for ngBootBox discusses the $ngBootbox.alert()
:
Returns a promise that is resolved when the dialog is closed.
Therefore, instead of passing a traditional callback
, you can chain onto the promise, like so:
$ngBootbox.alert({
size: "small",
title: "Error",
message: message,
backdrop: true,
closeButton: false,
})
.then(function () {
//do something when modal closed right?
console.log('hello');
});
Upvotes: 2