Skip to content

Angular 6 Confirmation message using ng-bootstrap modal

Notifications You must be signed in to change notification settings

ybrodsky/ng-confirmation-modal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Yael Brodsky
Jul 12, 2019
a73cc27 · Jul 12, 2019

History

29 Commits
Dec 18, 2017
May 22, 2019
Dec 18, 2017
Dec 18, 2017
Jul 12, 2019
Sep 27, 2018
Sep 27, 2018
Sep 27, 2018
Jul 12, 2019
Dec 18, 2017
Dec 18, 2017
May 22, 2019
Sep 27, 2018
Sep 27, 2018

Repository files navigation

Angular 6 Confirmation Modal using ng-bootstrap's modal

Installation

npm install --save ng-confirmation-modal

 import { ConfirmationModalModule } from 'ng-confirmation-modal';


 imports: [
  ConfirmationModalModule.forRoot({
   //optional global config

   //confirmBtnClass: 'btn btn-success',
   //confirmBtnText: 'Confirm',
   //cancelBtnClass: 'btn btn-danger',
   //cancelBtnText: 'Cancel',
   //modalSize: 'lg',
   //modalClass: 'some-modal-class'
  })
 ]

Usage

 <a
  ngConfirm
  [title]="'Confirm'"
  [message]="'Are you sure kiddo?'"
  [options]="options"
  (onConfirm)="confirmed()"
  (onCancel)="cancelled()"
 >
  Delete some very important stuff
 </a>
 options: any = {
 	confirmBtnClass: 'btn btn-success',      //DEFAULT VALUE
  confirmBtnText: 'Confirm',      				//DEFAULT VALUE
  cancelBtnClass: 'btn btn-danger',      //DEFAULT VALUE
  cancelBtnText: 'Cancel',      				//DEFAULT VALUE
  modalSize: 'lg',      							 //DEFAULT VALUE
  modalClass: ''      								//DEFAULT VALUE
 }

 confirmed() {
  console.log('confirmed');
 }

 cancelled() {
  console.log('cancelled');
 }

Todo

Done in a rush because couldn't find anything alike, so:

  • Add options to set classes and stuff
  • Make some tests
  • Set some global configs for messages and texts and classes and w/e
  • Have the way of setting config reviewed because I just went with my gut