Closing Twitter Bootstrap Modal From Angular Controller

后端 未结 8 813
时光说笑
时光说笑 2020-12-12 21:26

I have a modal window that I use to present a form to users. They enter the information and then press a button the has an ng-click. The server processes the request and s

相关标签:
8条回答
  • 2020-12-12 21:59
    **just fire bootstrap modal close button click event**
    var app = angular.module('myApp', []);
    app.controller('myCtrl',function($scope,$http){
      $('#btnClose').click();// this is bootstrap modal close button id that fire click event
    })
    
    --------------------------------------------------------------------------------
    
    <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
            </div>
            <div class="modal-body">
              <p>Some text in the modal.</p>
            </div>
            <div class="modal-footer">
              <button type="button" id="btnClose" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
          </div>
        </div>
      </div>
    

    just set modal 'close button' id as i set btnClose, for closing modal in angular you have to just fire that close button click event as i did $('#btnClose').click()

    0 讨论(0)
  • 2020-12-12 22:01

    You can do it with a simple jquery code.

    $('#Mymodal').modal('hide');
    
    0 讨论(0)
提交回复
热议问题