简体   繁体   中英

How to close ng-bootstrap modal

bootstrap in my angular 2 project. I have two buttons in my modal as well. Each button have a callback function as well. How can I implement modal close or call modal close from the button? Went through the document but, felt quiet hard to understand.

The following is my button config:

private _modalConfig: any = {
        title: 'Are you sure you want to delete this Lesson?',
        button: [{
            text: 'Delete',
            class: 'btn-delete',
            callback: ()=>{
                            console.log(event);
                            alert('this is Delete');
                          } 
        },
        {
            text: 'Cancel',
            class: 'btn-cancel',
            callback: ()=>{  
                            event.preventDefault(); 
                            alert('this is Cancel');
                          } 
        }]
    } 

If you are using ModalDirective, of ng2-bootstrap, then the proper method is

.hide() , which allows to manually close the modal.

If you are included the bootstrapjs into your site.

It should be like this:

angular.element('#modal').modal('hide');

This is the very basic way to close bootstrap modal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM