Open Bootstrap Modal Angularjs ng-click event

·

How to make business template with Bootstrap 4 and Angular 9?
Hello to all, In this post, I will tell you, How to open Open Bootstrap Modal Angularjs ng-click event?

Angularjs and Bootstrap both are very famous.

Here is working and tested code for Open Bootstrap Modal Angularjs ng-click event:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>
<body ng-app="myApp">

<!--Angular Js Code -->

<div  ng-controller="myCtrl">
<button ng-click='selectMe($event)' class="btn btn-info btn-lg">Click Me!!</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
      $scope.selectMe = function (event){
    $("#myModal").modal("show");
   
}
});
</script>
<!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
</body>
</html>

 If you have any query related to Angularjs and Bootstrap then feel free to ask.

Comments

6 responses to “Open Bootstrap Modal Angularjs ng-click event”

  1. rosi Avatar
    rosi

    It doesn’t work to me 🙁

  2. Ajay Malhotra Avatar

    Can you please tell me the issue and or I think, you have added latest version CDN’s.

    Thank you

  3. Maher Avatar
    Maher

    angular.js:14800 TypeError: $(…).modal is not a function

  4. Ajay Malhotra Avatar

    Please use latest CND’s.
    Thanks

  5. Ajay Malhotra Avatar

    It is working for me 🙂

  6. Ajay Malhotra Avatar

    I checked and it is working 🙂