ng-bs-modal-service
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

NgBsModalService

Modal Service for Angular and Bootstrap 5.

Getting started

Step 1: Install ng-bs-modal-service

NPM

npm install --save ng-bs-modal-service

YARN

yarn add ng-bs-modal-service

Step 2: Import the NgBsModalServiceModule

import { NgBsModalServiceModule } from 'ng-bs-modal-service';

@NgModule({
  declarations: [...],
  imports: [NgBsModalServiceModule],
  bootstrap: [...]
})
export class AppModule {}

Step 3: Add ng-bs-modal-service tag

Add in app-component.html

<ng-bs-modal-service></ng-bs-modal-service>

Usage

Data source:

constructor(private modalService: NgBsModalService) {}

showModal(modalBody: TemplateRef<any>) {
    this.modalService.open({
        header: 'Modal',
        body: modalBody
    }, { 
        customClass: { modalHeader: 'bg-danger text-white' }
    })
}

In template:

<button type="button" class="btn btn-primary" (click)="showModal(modalBody)">Show Modal</button>

<ng-template #modalBody>
    <img src="https://placehold.co/800x400" alt="placeholder">
</ng-template>

Interfaces

ModalService.open(content: NgBsModalServiceContent | TemplateRef<any>, options?: NgBsModalServiceOptions)

NgBsModalServiceContent {
    body: TemplateRef<any> | string,
    header?: TemplateRef<any> | string,
    footer?: TemplateRef<any>
}

NgBsModalServiceOptions {
    disabledBodyScroll?: boolean;
    size?: 'sm' | 'lg' | 'xl',
    staticBackdrop?: boolean,
    withoutClose?: boolean,
    customClass?: {
        modal?: string;
        modalHeader?: string,
        modalBody?: string;
        modalFooter?: string,
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i ng-bs-modal-service

Weekly Downloads

0

Version

0.0.2

License

none

Unpacked Size

70.6 kB

Total Files

18

Last publish

Collaborators

  • alvinkalango