ngx-bootstrap:模态打开为小而不是大

der*_*zay 3 twitter-bootstrap ngx-bootstrap angular

我从另一个组件调用一个模态,问题是我只能将它打开为小而不是大

comp1.html

<button type="button" class="btn btn-outline-primary btn-lg" (click)="openModal()">Upload
Run Code Online (Sandbox Code Playgroud)

comp1.ts

import {modalComponent} from '../pages/modals/new-modal';

private modalService: BsModalService

constructor(private modalService: BsModalService)

openModal() {
    this.bsModalRef = this.modalService.show(modalComponent);
 }
Run Code Online (Sandbox Code Playgroud)

modal.component.ts

constructor(private modalService: BsModalService, public bsModalRef: BsModalRef)
Run Code Online (Sandbox Code Playgroud)

modal.html

<div bsModal #newModal="bs-modal"  tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
      </div>
    </div>
 </div>
Run Code Online (Sandbox Code Playgroud)

Cha*_*dru 13

试试这样:

openModal() {
    this.bsModalRef = this.modalService.show(modalComponent, {class: 'modal-lg'});
}
Run Code Online (Sandbox Code Playgroud)


roh*_*hit 5

如果您想在打开模态时将数据传递给模态组件,

openModal() {
   const initialState = {
     data:"Test data"
   }
   this.bsModalRef = this.modalService.show(modalComponent, {initialState, class: 'modal-lg'});
}
Run Code Online (Sandbox Code Playgroud)