Bootstrap modal not displaying

后端 未结 19 1851
逝去的感伤
逝去的感伤 2020-12-29 01:52

I\'ve copied and pasted the example code from twitter bootstrap to create a basic modal window in my Rails 3.2 app:


19条回答
  •  天命终不由人
    2020-12-29 02:25

    If you are using angular and trying to create a directive that has a custom modal in it, the modal backdrop will show but the modal itself will not unless you set replace: true on your directive.

    Typescript Directive:

    export class myModalDirective implements ng.IDirective {
        static Register = () => {
            angular.module('app').directive('myModal', () => { return new myModalDirective () });
        }
        templateUrl = 'mymodal.html'    
    restrict = 'E';
        replace = true;
        scope = {
            show: '='
        }
        link = (scope: any, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => {
            var vm = this;
            scope.$watch(function () { return scope.show; }, function (vis) {
                if (vis) {
                    $(element).modal('show');
                } else {
                    $(element).modal('hide');
                }
            });
    
        }
        constructor () {
        }
    }
    

    Modal HTML

    
    

提交回复
热议问题