panagulis72 panagulis72 - 7 months ago 27
Javascript Question

BlockUI during a function in Angular

In a web-app there is a button which call a function. How can I do if I want to insert a blockUI during the operation? Have I do a promise? Where in particular?

$scope.eraseDB = function(){
database.destroylocalDB();
};


the function:

destroylocalDB: function(){

localDB.destroy().then(function (response) {
//Remove cache
datacache.dr = [];
database.initDB();
}).catch(function (err) {
console.log(err);
});
}

Answer

Have you looked the Angular BlockUI?

Take a look at the documentation. After configuration, you will just need to:

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);
  });       
}
Comments