【问题标题】:Accordion/Modal not at the top using ionic使用离子手风琴/莫代尔不在顶部
【发布时间】:2015-09-04 13:22:21
【问题描述】:

有一个我需要使用 ionic 实现的地图应用程序的屏幕 它有一张地图和一个允许查看地图一部分的列表。 尝试模拟本机行为,我需要在单击地图时显示地图,将列表向下移动。 有什么办法处理吗?

【问题讨论】:

    标签: dictionary mobile ionic-framework ionic


    【解决方案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
      });
    });
    

    【讨论】:

    • 是个好主意,但我看到的缺点是:* 我需要在模态框内包装导航 * 在 ipad 上看起来有点奇怪,但在 iPhone 上却很完美
    • 啊,你想对列表使用同样的行为吗?我可能可以做到这一点。它可能就像在显示列表时使用 ng-class 使标题透明一样简单。但是,我认为模态是唯一出现在其他东西上的东西。对于 I pad,您可能只需编辑模态框,使其像在手机上一样占据整个屏幕。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    • 2021-06-26
    相关资源
    最近更新 更多