答案 0 :(得分:1)
所以这有点开箱即用,但你没有发布任何代码,所以我只是想发布它。您可以在顶部使用带有透明div的模态,其上有一个closeModal单击事件。像这样: 还可以查看playground
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="http://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet">
<script src="http://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>
</head>
<body ng-app="app">
<ion-pane >
<ion-header-bar class="bar-stable">
<h1 class="title">Awesome App</h1>
</ion-header-bar>
<ion-content class="has-header" ng-controller="main">
<button class="button button-assertive" ng-click="openModal()">I'm a button</button>
</ion-content>
</ion-pane>
<script id="my-modal.html" type="text/ng-template">
<div style="filter:alpha(opacity=50); opacity:0.5;height: 70px;" ng-click="closeModal()">........</div>
<ion-modal-view style="height: 90%; top: 10%;">
<ion-header-bar>
<h1 class="title">My Modal title</h1>
</ion-header-bar>
<ion-content>
Hello!
</ion-content>
</ion-modal-view>
</script>
</body>
</html>
JS:
angular.module('app', ['ionic']).controller('main', function($ionicModal, $scope){
$ionicModal.fromTemplateUrl('my-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
});