2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UI BootstrapのModalが取り残されるのを回避する方法

2
Last updated at Posted at 2016-05-31

AngularJSとUI BootstrapでModalを表示するとブラウザの戻るボタンを押したり、ChromeだとBackspaceキーを押して前の画面に戻ったときに取り残されてしまう。

回避方法

sample.js
$rootScope.$on('$locationChangeStart', function() {
  if ($uibModalInstance.opened) {
    $uibModalInstance.dismiss('cancel');
  }
});

$locationChangeStartでURLの変更を検知して、閉じてあげる。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?