我使用ngBootbox来 self 的 AngularJS 应用程序中的 eriktufvesson,如 BootBox.js Documentation 中所述如何在alert中使用回调函数:
bootbox.alert({
message: "This is an alert with a callback!",
callback: function () {
console.log('This was logged in the callback!');
}
})
这是我的代码:
$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!
}
});
那么,如何让 ngBootBox 警报回调函数在 AngularJS 应用程序中工作?
请赐教。
*注: 我也使用 ngBootBox 确认,它工作得很好,我只是不知道如何处理 ngBootbox 警报回调函数。
最佳答案
documentation for ngBootBox讨论 $ngBootbox.alert()
:
Returns a promise that is resolved when the dialog is closed.
因此,您可以链接到 Promise,而不是传递传统的回调
,如下所示:
$ngBootbox.alert({
size: "small",
title: "Error",
message: message,
backdrop: true,
closeButton: false,
})
.then(function () {
//do something when modal closed right?
console.log('hello');
});
关于javascript - ngBootBox 回调函数不起作用(AngularJS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46131655/