离子滑动菜单单击被选中但不会将打开的菜单滑动到屏幕上

时间:2016-07-03 17:24:32

标签: angularjs ionic-framework hybrid-mobile-app hybrid

当您单击菜单按钮时,我的应用程序滑动菜单没有做任何事情,不确定我缺少什么。它会为滑动菜单创建按钮,当您单击它时会注册它已被单击但没有将菜单滑动到屏幕上。对不起这个基本问题我是离子和角度JS的新手。不知道我在哪里出错了,因为我正在关注如何将滑动菜单添加到应用程序中的离子文档。

的index.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">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB16sGmIekuGIvYOfNoW9T44377IU2d2Es&sensor=true"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/directives.js"></script>
  </head>

  <body ng-app="starter" animation="slide-left-right-ios7" ng-controller="MapCtrl">
<ion-header-bar class="bar-dark">

  <button class="button button-icon" ng-click="toggleSideMenu">
    <i class="icon ion-navicon"></i>
  </button>



  <h1 class="title">TekIT</h1>
</ion-header-bar>

    <ion-content scroll="false">
      <map on-create="mapCreated(map)"></map>
    </ion-content>

    <ion-footer-bar class="bar-stable">
      <ion-tabs>

      <ion-tab title="Mac" icon-off="ion-social-apple" icon-on="ion-social-apple" href="#/app/search">
        <ion-nav-view name="tab-search"></ion-nav-view>
      </ion-tab>

      <ion-tab title="Windows" icon-off="ion-social-windows" icon-on="ion-social-windows" href="#/app/browse">
        <ion-nav-view name="tab-browse"></ion-nav-view>
      </ion-tab>

      <ion-tab title="Mobile" icon-off="ion-iphone" icon-on="ion-iphone" href="#/app/playlists">
        <ion-nav-view name="tab-playlists"></ion-nav-view>
      </ion-tab>
      <ion-tab title="Other" icon-off="ion-wifi" icon-on="ion-wifi"" href="#/app/playlists">
        <ion-nav-view name="tab-playlists"></ion-nav-view>
      </ion-tab>

    </ion-tabs>
    </ion-footer-bar>
  </body>
</html>

menu.html

<ion-side-menus enable-menu-with-back-views="false">
  <ion-side-menu-content>

    <ion-nav-bar class="bar-stable">
      <ion-nav-back-button>
      </ion-nav-back-button>


      <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
        </button>
      </ion-nav-buttons>
    </ion-nav-bar>
    <!-- TABS -->
    <ion-tabs>

      <ion-tab title="Search" icon-off="ion-search" icon-on="ion-search" href="#/app/search">
        <ion-nav-view name="tab-search"></ion-nav-view>
      </ion-tab>

      <ion-tab title="Browse" icon-off="ion-ios-glasses" icon-on="ion-ios-glasses" href="#/app/browse">
        <ion-nav-view name="tab-browse"></ion-nav-view>
      </ion-tab>

      <ion-tab title="Playlist" icon-off="ion-ipod" icon-on="ion-ipod" href="#/app/playlists">
        <ion-nav-view name="tab-playlists"></ion-nav-view>
      </ion-tab>

    </ion-tabs>

  </ion-side-menu-content>

   <!-- Side Menu (left) -->
  <ion-side-menu side="left">
    <ion-header-bar class="bar-stable">
      <h1 class="title">Left</h1>
    </ion-header-bar>
    <ion-content>
      <ion-list>
        <ion-item menu-close ng-click="login()">
          Login
        </ion-item>
        <ion-item menu-close href="#/app/search">
          Search
        </ion-item>
        <ion-item menu-close href="#/app/browse">
          Browse
        </ion-item>
        <ion-item menu-close href="#/app/playlists">
          Playlists
        </ion-item>
      </ion-list>
    </ion-content>
  </ion-side-menu>
</ion-side-menus>

app.js

var app = angular.module('starter', ['ionic', 'starter.controllers', 'starter.directives'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

controller.js

angular.module('starter.controllers', [])

//toggleSideMenu
.controller('toggleSideMenu', function($scope, $ionicLoading) {
    $scope.alert("TEST!");
})

.controller('MapCtrl', function($scope, $ionicLoading) {
  $scope.toggleSideMenu = function() {
      alert("TEST!");
  };

  $scope.mapCreated = function(map) {
    $scope.map = map;
  };


  $scope.centerOnMe = function () {
    console.log("Centering");
    if (!$scope.map) {
      return;
    }

    $scope.loading = $ionicLoading.show({
      content: 'Getting current location...',
      showBackdrop: false
    });

    navigator.geolocation.getCurrentPosition(function (pos) {
      console.log('Got pos', pos);
      $scope.map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
      $scope.loading.hide();
    }, function (error) {
      alert('Unable to get location: ' + error.message);
    });
  };
})

0 个答案:

没有答案