我有一个如下所示的模态弹出窗口
<script type="text/ng-template" id="myTestModal.tmpl.html">
<div class="modal-header">
<h3>Warning!</h3>
</div>
<div class="modal-body">
<p>You have unsaved data. Continue to close?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" ng-click="close(true)" data-dismiss="modal">Yes
</button>
<button type="button" class="btn btn-success" ng-click="close(false)">No
</button>
</div>
</script>
然后在我有的 js 文件中,
vm.openModal = function(){
$scope.modalInstance = $modal.open({
templateUrl: 'myTestModal.tmpl.html',
scope: $scope
});
}
$scope.close = function(isClose){
$scope.modalInstance.close();
};
但是 $scope.modalInstance.close();当用户单击是或否时不起作用。用户必须单击 2 次才能关闭弹出窗口。让我知道任何想法。
`