MD Ghouse MD Ghouse - 1 month ago 11
AngularJS Question

Why bootstrap modal not hiding its popup

Here i'm using Angular with Bootstrap here when i Click on * Icon or click on CLOSE button why modal not hiding

<div class="modal" id="modalSuccess">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button class="close" data-toggle="modal" data-target="#modalSuccess">&times;</button>
<h4 style="color:green">{{msg}}</h4>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-success btn-sm" value="Close" ng-click="okCloseBtn()" />
</div>
</div>
</div>
</div>


Angular.Js

$scope.okCloseBtn = function () {
alert('in closer')
$('#modalSuccess').modal('hide');
}


Here alert is working please give me answer where I'm doing wrong

Answer

You need to use $modalInstance

 $scope.okCloseBtn = function () {
    $modalInstance.dismiss('cancel');
  };