AngularJS - 可以ng-show / ng-hide模态窗口?

时间:2015-11-04 15:15:02

标签: javascript html angularjs angular-ui-bootstrap

我希望在关闭时保持我的bootstrap.ui(或ngdialog !!)模态窗口的状态。知道如何展示/隐藏模态窗口吗?

感谢。

1 个答案:

答案 0 :(得分:6)

看一下这个例子:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<div ng-app>
    <div ng-init="showModal=false">
        <button class="btn btn-primary btn-lg" ng-click="showModal = !showModal">
            Launch demo modal
        </button>
        <div class="modal fade in" aria-hidden="false" style="display: block;" ng-show="showModal">  
            <div class="modal-dialog">    
                <div class="modal-content">   
                    MODAL   
                    <div class="modal-footer">        
                        <button type="button" class="btn btn-primary" ng-click="showModal=false">Ok</button>     
                    </div>    
                </div>  
            </div>
        </div>
    </div>
</div>