Add Add Add

How to close a bootstrap modal programmatically using AngularJS

525 Views Asked by At

I have a tab view which has a button to open a modal.

<button class="btn btn-primary btn-etis" data-toggle="modal" data-target="#addModal">Add</button>

The modal is opened via ng-include and by its referencing its name which is 'addModal'

<div ng-include=" 'register/individual/views/modal/addBookOfAccounts.html' "></div>

Here is my modal code:

<!-- Add BOA Modal-->
<ng-form  class="form-etis" name="addBoaForm" method="post">
<div class="modal fade" id="addModal" tabindex="-1" role="dialog"
    aria-labelledby="addIdentificationModalLabel" aria-hidden="true"
    data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-title" id="addModalLabel">
                    <div class="no-margin no-padding">
                        <i class="fa fa-book"></i> NEW Book of Account Details
        </div>
    </div>
</div>
<div class="pull-right">
    <a class="btn btn-primary btn-etis" href=""
        ng-click="ctrl.submitBoaForm()">Ok</a> 
            <a class="btn btn-danger btn-etis" href=""
       data-dismiss="modal" role="button" ng-click="ctrl.closeBoaForm()">Cancel</a>
</div>

inside my controller

self.submitBoaForm = function () {
                if (self.isBoaFormValid()) {
                    self.bookOfAccountsGrid.data.push(self.bookOfAccounts);
                    self.resetBoaDetails();
                    alert('New BOA Saved');
                } else {
                    console.log('invalid boa form')
                }
            }

            self.closeBoaForm = function () {
                self.showBoaFormValidations = false;
                self.resetBoaDetails();
            };

I am able to display the modal just by using data-target. My only problem is on how do i close the modal programmatically inside the submitBoaForm() after the alert method?

0

There are 0 best solutions below