ngx-bootstrap模态(ng6 / bs4)与angular2-draggable一起使用,不会拖动整个模态,只是里面的东西

问题描述 投票:1回答:1

所以,我有一个在ng6和bs4.x中完成的应用

我已经从此处安装了angular2 / draggable:Angular Draggable

并且我已经在此使用模态示例:ngx-bootstrap/modal

如果向下滚动到:Component#,您将看到下面的示例。

模板:

<button type="button" class="btn btn-primary" (click)="openModalWithComponent()">Create modal with component</button>

组件:

从'@ angular / core'导入{Component,OnInit};从'ngx-bootstrap / modal'导入{BsModalService,BsModalRef};

@Component({
  selector: 'demo-modal-service-component',
  templateUrl: './service-component.html'
})
export class DemoModalServiceFromComponent {
  bsModalRef: BsModalRef;
  constructor(private modalService: BsModalService) {}

  openModalWithComponent() {
    const initialState = {
      list: [
        'Open a modal with component',
        'Pass your data',
        'Do something else',
        '...'
      ],
      title: 'Modal with component'
    };
    this.bsModalRef = this.modalService.show(ModalContentComponent, {initialState});
    this.bsModalRef.content.closeBtnName = 'Close';
  }
}

/* This is a component which we pass in modal*/

@Component({
  selector: 'modal-content',
  template: `
    <div class="modal-header">
      <h4 class="modal-title pull-left">{{title}}</h4>
      <button type="button" class="close pull-right" aria-label="Close" (click)="bsModalRef.hide()">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    <div class="modal-body">
      <ul *ngIf="list.length">
        <li *ngFor="let item of list">{{item}}</li>
      </ul>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" (click)="bsModalRef.hide()">{{closeBtnName}}</button>
    </div>
  `
})

export class ModalContentComponent implements OnInit {
  title: string;
  closeBtnName: string;
  list: any[] = [];

  constructor(public bsModalRef: BsModalRef) {}

  ngOnInit() {
    this.list.push('PROFIT!!!');
  }
}

可拖动功能确实起作用,但在我的示例中,将发生这种情况:

最后,这是我的@component({...})

我曾经用上面的代码替换ngx-bootstrap的代码中的基本模态...

The Modal as it appears when opened

The Modal when I try to DRAG the container but the modal-content moves OUTSIDE of the container

Here's the way the modal looks inside the Elements Tab of Google

请告知...

bootstrap-4 angular6 ngx-bootstrap
1个回答
0
投票

我使用CSS解决此问题:

.modal-dialog {
  .modal-content {
    background-color: transparent;
    border: none;
    box-shadow: none;
  }
  .ngDraggable {
    box-shadow: 0 5px 15px rgba(0,0,0,.5);
    border-radius: 6px;
    border: 1px solid #999;
    overflow: hidden;
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.