javascript AngularJS - 可以 ng-show/ng-hide 模式窗口吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33525361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 16:35:42  来源:igfitidea点击:

AngularJS - Possible to ng-show/ng-hide a modal window?

javascripthtmlangularjsangular-ui-bootstrap

提问by notAChance

I want to keep the state of my bootstrap.ui (OR ngdialog!!) modal window when it is closed. Any idea how I might ng-show/ng-hide a modal window?

我想在关闭时保持我的 bootstrap.ui(或 ngdialog!!)模态窗口的状态。知道如何 ng-show/ng-hide 模态窗口吗?

Thanks.

谢谢。

回答by Emir Marques

Look this example:

看这个例子:

<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>