Angular UI Bootstrap Modal - how to prevent user interaction

戏子无情 提交于 2019-12-08 14:32:23

问题


In my current usecase, I am trying to use angular-ui modal window to show the progress of calculations that we do in a background process which we disable on completion.

All works well. I just want to disable user from clicking any of element in background.

Any idea how can we do this?


回答1:


You can pass the following options, when opening a modal window, to prevent users from closing the window:

  • backdrop: 'static' - top prevent users from closing a modal on backdrop click
  • keyboard: false - so users can't close a window by pressing ESC

Full documentation here: http://angular-ui.github.io/bootstrap/#/modal




回答2:


I just want to add an example with code and extend pkozlowski.opensource answer, Check this example:

    var modalInstance = $modal.open({
        templateUrl: '/views/registration/loginModal.html',
        controller: LoginModalInstanceCtrl,
        windowClass: 'login-modal-window',
        resolve : { 
          credentials : function(){ return {email :'', password:''}; }
        },
        backdrop: 'static', /*  this prevent user interaction with the background  */
        keyboard: false
      });

      modalInstance.result.then(function (res) {

      }, function () {
         /*  cancel */
         $state.go('home');
  });


来源:https://stackoverflow.com/questions/20371227/angular-ui-bootstrap-modal-how-to-prevent-user-interaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!