我在我的angularjs应用中使用来自eriktufvesson的ngbootbox,如bootbox.js文档中所述如何在警报中使用回调函数:
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警报回调函数在gangularjs应用中工作?
请给我启蒙。
*注意:我还使用ngbootbox确认,它正在工作,我只是不知道如何处理ngbootbox警报回调函数。
ngbootbox的文档讨论 $ngBootbox.alert()
:
返回对话框关闭时解决的承诺。
因此,您可以像这样的诺言,而不是传统的callback
,而是这样:
$ngBootbox.alert({
size: "small",
title: "Error",
message: message,
backdrop: true,
closeButton: false,
})
.then(function () {
//do something when modal closed right?
console.log('hello');
});