Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngx-bootstrap: Modal opens up as small instead of large

I am calling a modal from another component and the problem is I can only get it to open as small, not as large

comp1.html

<button type="button" class="btn btn-outline-primary btn-lg" (click)="openModal()">Upload

comp1.ts

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

private modalService: BsModalService

constructor(private modalService: BsModalService)

openModal() {
    this.bsModalRef = this.modalService.show(modalComponent);
 }

modal.component.ts

constructor(private modalService: BsModalService, public bsModalRef: BsModalRef)

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>

like image 494
derrickrozay Avatar asked Oct 18 '17 17:10

derrickrozay


People also ask

How do I make bootstrap modal bigger?

Change the size of the modal by adding the . modal-sm class for small modals, . modal-lg class for large modals, or . modal-xl for extra large modals.

How do I change the default height of a bootstrap modal box?

modal-body use calc() function to calculate desired height. In above case we want to occupy 80vh of the viewport, reduced by the size of header + footer in pixels. This is around 140px together but you can measure it easily and apply your own custom values. For smaller/taller modal modify 80vh accordingly.

How do I center a modal in bootstrap NGX?

Add . modal-dialog-centered to . modal-dialog to vertically center the modal.


2 Answers

Try like this :

openModal() {
   this.bsModalRef = this.modalService.show(modalComponent, { class: 'modal-lg' });
}
like image 82
Chandru Avatar answered Oct 04 '22 21:10

Chandru


If you want to pass data to modal component while opening modal,

openModal() {
   const initialState = {
     data:"Test data"
   }
   this.bsModalRef = this.modalService.show(modalComponent, {initialState, class: 'modal-lg'});
}
like image 37
rohit Avatar answered Oct 04 '22 21:10

rohit