【问题标题】:ngBootBox Callback Function Not Working (AngularJS)ngBootBox 回调函数不起作用(AngularJS)
【发布时间】:2017-09-09 14:24:20
【问题描述】:

我在我的 AngularJS 应用程序中使用来自 eriktufvesson 的 ngBootbox,如 BootBox.js Documentation 如何在警报中使用回调函数所述:

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 警报回调函数。

【问题讨论】:

    标签: javascript angularjs bootbox


    【解决方案1】:

    documentation for ngBootBox 讨论$ngBootbox.alert()

    返回一个在对话框关闭时解决的承诺。

    因此,您可以链接到 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');
    });
    

    【讨论】:

    • 我没有看到,它在文档本身的首页,我现在觉得很愚蠢。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多