AngularJS - 关闭模态窗口

Jas*_*per 6 twitter-bootstrap angularjs angular-ui-bootstrap

我的包括:

bootstrap.css [ getbootstrap.com/2.3.2 ]
angular/ui-bootstrap-tpls-0.10.0.min.js from: [ angular-ui.github.io/bootstrap ]
Run Code Online (Sandbox Code Playgroud)

我正在使用AngularJS和Twitter Bootstrap.

从AngularJS我打开模态窗口如下:

var modalInstance = $modal.open({
              templateUrl: 'resources/html/mymodal.html',
              controller: 'mymodalController',
              scope: $scope
            });
Run Code Online (Sandbox Code Playgroud)

我的模态模板是:

<div class="modal">
<
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
  </div>
.....
</div>
Run Code Online (Sandbox Code Playgroud)


问题:
关闭[x]按钮不起作用
当我点击它时,模态不会消失.但是当我按Esc时 - 模态消失了.
所以看起来...... data-dismiss ="modal"不起作用.有任何想法吗?

Jer*_*eir 12

data-dismiss属性由bootstrap javascript使用(因为我看到你有来自http://getbootstrap.com/javascript/#modals的html源代码)

UI Bootstrap不会绑定到该关闭按钮,因为它没有查找该属性,您需要添加ng-click并关闭模式,如示例中所示

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

在控制器中:

$scope.cancel = function () {
    $modalInstance.dismiss('cancel');
};
Run Code Online (Sandbox Code Playgroud)

模态模板......

<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
Run Code Online (Sandbox Code Playgroud)