[英]AngularJS - Closing Modal Window
My includes are: 我的包括:
bootstrap.css [ getbootstrap.com/2.3.2 ]
angular/ui-bootstrap-tpls-0.10.0.min.js from: [ angular-ui.github.io/bootstrap ]
I am using AngularJS and Twitter Bootstrap. 我正在使用AngularJS和Twitter Bootstrap。
From AngularJS I open the modal window as follows: 从AngularJS我打开模态窗口如下:
var modalInstance = $modal.open({
templateUrl: 'resources/html/mymodal.html',
controller: 'mymodalController',
scope: $scope
});
My Modal Template is: 我的模态模板是:
<div class="modal">
<
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
.....
</div>
Question: 题:
The close [x] button is not working 关闭[x]按钮不起作用
When I click on it, the modal does not go away. 当我点击它时,模态不会消失。 But when I press Esc - the modal vanishes. 但是当我按Esc时 - 模态消失了。
So looks like ... data-dismiss="modal" is not working. 所以看起来...... data-dismiss =“modal”不起作用。 Any ideas? 有任何想法吗?
the data-dismiss
attribute is used by the bootstrap javascript (as I see you got the html source code from, http://getbootstrap.com/javascript/#modals ) data-dismiss
属性由bootstrap javascript使用(因为我看到你有来自http://getbootstrap.com/javascript/#modals的html源代码)
UI Bootstrap won't be binding to that close button because it isn't looking for that attribute, you need to add an ng-click and dismiss the modal like in the examples UI Bootstrap不会绑定到该关闭按钮,因为它没有查找该属性,您需要添加ng-click并关闭模式,如示例中所示
http://angular-ui.github.io/bootstrap/#/modal http://angular-ui.github.io/bootstrap/#/modal
in controller: 在控制器中:
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
Modal template... 模态模板......
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
In angular, there is a close
method of $modalInstance
to close a opened modal window . 在angular中,有一个$modalInstance
的close
方法来关闭打开的模态窗口。
Controller : 控制器:
$scope.closeMyPopup = function () {
$modalInstance.close();
};
我这样使用带有Angular的jQuery:
jQuery('#YOURMODALID').modal('hide');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.