我的包括:
bootstrap.css [ getbootstrap.com/2.3.2 ]
angular/ui-bootstrap-tpls-0.10.0.min.js from: [ angular-ui.github.io/bootstrap ]
我正在使用 AngularJS 和 Twitter Bootstrap。
从 AngularJS 我打开模态窗口如下:
var modalInstance = $modal.open({
templateUrl: 'resources/html/mymodal.html',
controller: 'mymodalController',
scope: $scope
});
我的模态模板是:
<div class="modal">
<
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
.....
</div>
问题:
关闭 [x] 按钮不起作用
当我单击它时,模态不会消失。但是当我按下 Esc - 模式消失了。
所以看起来...... data-dismiss="modal"不起作用。有任何想法吗?
最佳答案
data-dismiss
属性由 Bootstrap javascript 使用(我看到你从 http://getbootstrap.com/javascript/#modals 获得了 html 源代码)
UI Bootstrap 不会绑定(bind)到那个关闭按钮,因为它不是在寻找那个属性,你需要添加一个 ng-click 并像示例中那样关闭模式
http://angular-ui.github.io/bootstrap/#/modal
在 Controller 中:
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
模态模板...
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
关于AngularJS - 关闭模态窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26154726/