I use angular -ui to open and close modal. When I close it with submit(object) or dismiss(message) , the dialog box closes, but the screen remains gray and I cannot access my application. Some code:
Parent controller (corresponding part):
$scope.deleteConfirm = function(toDelete) { console.log(toDelete); var modalObj = { templateUrl: 'views/templates/delete.html', controller: 'DeleteCtrl', size: 'sm', resolve: { toDelete: function() { return toDelete; }, collection: function() { return $scope.users; } } } var modalInstance = $modal.open(modalObj); modalInstance.result.then(function (deletedItem) { console.log(deletedItem); });
};
Parent html:
<button class="btn btn-danger btn-xs" ng-click="deleteConfirm(user)">X</button>
Modal Controller:
.controller('DeleteCtrl', ['$scope', '$modalInstance', 'toDelete', 'collection', function ($scope, $modalInstance, toDelete, collection) { $scope.toDelete = toDelete; $scope.remove = function() { collection.$remove(toDelete).then(function(ref) { $modalInstance.close(ref); }); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }]);
Modal template:
<div class = "ll-modal"> <div class="modal-header"> <h3 class="modal-title">Confirm Delete</h3> </div> <div class="modal-body"> Are you sure you want to delete this item? It will be gone forever. </div> <div class="modal-footer"> <button class="btn btn-primary" ng-click="remove()">Delete Permanently</button> <button class="btn btn-warning" ng-click="cancel()">Cancel</button> </div>
source share