1

We had to update the Bootstrap version (bs3 to bs4). We have some issues with Angularjs modal.It only works in bs3.4.1 version not even 3.4.2. Below is a similar piece of code, the problem is, It looks like a template has been added to the dom, but the modal doesn't appear and behave like a modal. How can I solve this problem. Any help will be really appreciated.

<html>
    <head runat="server">
        <title></title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.js"></script>       
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.0/ui-bootstrap-tpls.min.js"></script>               
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" rel="stylesheet" />     
        
        <script type="text/javascript">
          
            var app = angular.module("app", ['ui.bootstrap']);
app.controller("democontroller", ["$scope", "$modal", function($scope, $uibModal){
    $scope.click = function(){
   $uibModal.open({
      templateUrl: "modal.html",
      controller: "modal",
      scope: $scope
    });
  }
}]);

app.controller("modal", modal);

function modal() {
    console.log("in modal controller")
}

        </script>
    </head>
<body>
    <div ng-app="app" ng-controller="democontroller">
        <button type="button" class="btn btn-default" ng-click="click()">
          Open modal
        </button>
      <script type="text/ng-template" id="modal.html">
          <h1>modal</h1>
      </script>
      </div>
</body>
</html>

1 Answers1

0

If you change your style link to this (in the shaded area below) the modal should work. I got the link from here fyi: https://getbootstrap.com/docs/3.3/getting-started/

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
Gerald LeRoy
  • 1,227
  • 2
  • 11
  • 17
  • 1
    thank you for answer @Gerald, I followed this step and it worked. [link](https://stackoverflow.com/questions/42690497/angular-ui-modal-with-bootstrap-4/42690766) – HakanKaraoglu Jan 27 '22 at 16:01