ngBootBox 回调函数不工作 (AngularJS)

ngBootBox Callback Function Not Working (AngularJS)

我用ngBootbox from eriktufvesson in my AngularJS app and as stated in 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!
    }
});

那么,如何让AngularJS应用程序中的ngBootBox警报回调函数起作用?

请赐教

*注: 我也使用 ngBootBox confirm 并且它工作得很好,我只是不知道如何处理 ngBootbox 警报回调函数。

documentation for ngBootBox 讨论 $ngBootbox.alert():

Returns a promise that is resolved when the dialog is closed.

因此,您可以像这样链接到 promise,而不是传递传统的 callback

$ngBootbox.alert({
    size: "small",
    title: "Error",
    message: message,
    backdrop: true,
    closeButton: false,
})
.then(function () {
    //do something when modal closed right?
    console.log('hello');
});