手风琴/模态不在顶部使用离子

时间:2015-09-04 13:22:21

标签: dictionary mobile ionic-framework ionic

为我需要使用离子实现的地图应用程序设置了一个屏幕 它有一个地图和一个列表,可以看到地图的一部分。 尝试模拟本机行为,我需要在点击它时显示地图,向下移动列表。 有任何线索如何处理它?<​​/ p>

Notes List

1 个答案:

答案 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
  });
});