How to hide/show same modal instance with AngularJS?

旧时模样 提交于 2019-12-04 02:16:13

To create/hide a ng-strap modal you can use it like this:

     var modalInstance;
        $scope.open = function() {    
            modalInstance= $modal.open({
                   templateUrl: 'myModalContent.html',
                   controller: ModalInstanceCtrl,        
            });
 //This is how to show the modal.

        modalInstance.$promise.then(modalInstance.show);
        };

    //When u want to hide the modal use this as written below:    
    $scope.close = function() {
        modalInstance.hide();
    };

To create a modal you can do so like this:

var planModal = $modal({scope: $scope,
            template: 'modalTemplate.html',
            show: false});

the "show" attribute is set to false which stops the modal from displaying when it is loaded.

To display this modal we can then do so like this:

planModal.$promise.then(planModal.show);

Similarly, to hide this modal we can do so like this:

planModal.$promise.then(planModal.hide);

Hmmmm struggled with this the best thing to do its just to use css following rules can be used to show/hide modal window

 angular.element('.modal').css('display', 'none');// to hide the modal
 angular.element('.modal').css('display', 'block');// to show the modal
irfanka

Showing/hiding the same modal instance is not possible (in a nice, clean way, at least), but you might still be able to speed things up a bit. How to do that depends on what you mean by thumbnail generation.

In other words, if it's slow because it takes long time to download all images, then a possible solution would be to pre-download all images so that they are already cached by the browser by the time you try to show the dialog. This answer explains how to do that.

On the other hand, if by 'thumbnail generation' you mean actually rendering thumbnails once all assets are downloaded, and that takes a long time, then you might want to take a look at your css, and see if you can simplify anything to make the browser's job easier.

     <div class="modal fade in" id="invoice_popup" ng-show="showInvModal" data-backdrop="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <!--3rd next popup-->
                <div id="Div2" class="modal-dialog" style="width: 40%;">
                    <div class="modal-content" style="margin-top:6%;margin-left:8%;">
                        <div class="modal-header" style="padding:6px;">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size:30px;">&times;</button>
                            <h4 class="modal-title" id="H1"><label>Invoice Summary</label></h4>

                        </div>
                        <div class="modal-body" style="padding:5px;">
    </div>
                        <div class="modal-footer">
                            <div class="draft-btn-bottom">
                                <a href="JavaScript:viod(0);" ng-click="make_invoice()">Save</a>
                                <a href="JavaScript:viod(0);" data-dismiss="modal">Cancel</a>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

    // angular js controler code in a function
$scope.Open_Modal_Popup = function () {
     var popup_inv = angular.element("#invoice_popup");
                popup_inv.modal('show');
               $scope.showInvModal = true;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!