如何在指令链接函数中打开和关闭Bootstrap模式弹出?

时间:2016-12-29 09:10:40

标签: angularjs angular-ui-bootstrap angular-directive angular-services

我需要在某个函数下打开bootstrap模式弹出里面的指令,怎么能用in指令。

而不是这些需要使用angualr来打开对话框。

 var show = function () {
                    $('#myModal1').modal({ backdrop: 'static', keyboard: false });
                    $element.css('display', 'block');

                };

喜欢隐藏角度

 var hide = function () {
                    $('#myModal1').modal(toggle);
                    $element.css('display', 'none');
                };


myApp.directive('loadingStatusMessage', function () {
        return {
            link: function ($scope, $element, attrs) {
                var show = function () {
                    $('#myModal1').modal({ backdrop: 'static', keyboard: false });
                    $element.css('display', 'block');

                };
                var hide = function () {
                    $('#myModal1').modal(toggle);
                    $element.css('display', 'none');
                };
                $scope.$on('loadingStatusActive', show);
                $scope.$on('loadingStatusInactive', hide);
                hide();
            }
        };
    });

HTML:

<div class="modal fade" id="myModal1" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" loading-status-message
     style="position:fixed; display:none;">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <button type="button" class="close"
                            data-dismiss="modal"
                            aria-label="Close">
                       <span aria-hidden="true">&times;</span>
                    </button>
                    <div class="alert alert-success" role="alert">
                        <strong>Technical Error Occurred.Please contact the System Administrator for the further support!!</strong>
                    </div>
                </div>
            </div>
        </div>
    </div>  

0 个答案:

没有答案