2
當我單擊背景時,我不希望模態消失。我希望它保持顯示,直到我點擊模式內的按鈕。這裏是一個codepen鏈接單擊模式外部時阻止關閉基礎模式
http://codepen.io/anon/pen/JdNXGd
這裏是角碼
app = angular.module('app', ['ngAnimate']);
app.directive('modal', function() {
return {
restrict: 'E',
scope: {
show: '='
},
replace: true, // Replace with the template below
transclude: true, // we want to insert custom content inside the directive
link: function(scope, element, attrs) {
scope.hideModal = function() {
scope.show = false;
};
},
template: "<div class='ng-modal' ng-show='show'>"+
"<div class='reveal-modal' data-options='close_on_background_click:false' ng-show='show'>"+
"<div ng-transclude></div>"+
"<a class='close-reveal-modal' ng-click='hideModal()'>×</a>"+
"</div>"+
"<div class='reveal-modal-bg' ng-click='hideModal()'></div>"+
"</div>"
};
});
app.controller('AppCtrl', ['$scope', function($scope) {
$scope.modalShown = false;
$scope.toggleModal = function() {
$scope.modalShown = !$scope.modalShown;
};
}]);