在网络应用程序中有一个调用函数的按钮。运行中想插入blockUI怎么办?我答应了吗?具体在哪里?
$scope.eraseDB = function(){
database.destroylocalDB();
};
函数:
destroylocalDB: function(){
localDB.destroy().then(function (response) {
//Remove cache
datacache.dr = [];
database.initDB();
}).catch(function (err) {
console.log(err);
});
}
最佳答案
你看过Angular BlockUI了吗? ?
看看 documentation .配置后,您只需要:
destroylocalDB: function(){
blockUI.start();
localDB.destroy().then(function (response) {
blockUI.stop();
//Remove cache
datacache.dr = [];
database.initDB();
}).catch(function (err) {
blockUI.stop();
console.log(err);
});
}
编辑:
要执行您想要的操作,您需要更改服务以返回 promise :
destroylocalDB: function(){
return localDB.destroy().then(function (response) {
//Remove cache
datacache.dr = [];
database.initDB();
}).catch(function (err) {
console.log(err);
});
}
所以你可以:
$scope.eraseDB = function(){
blockUI.start();
database.destroylocalDB().then(function(){
blockUI.stop();
});
};
我没有测试,但应该可以。
关于javascript - 在 Angular 中执行 BlockUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36917356/