在Ionic1中单击同一按钮时隐藏和显示模态

时间:2018-01-22 11:37:15

标签: html angularjs ionic-framework

我想隐藏并根据相同的按钮点击显示div

点击部分

<a class = "tab-item" ng-click="showDetails = ! showDetails">
   <i class = "icon  ion-paperclip"></i>
     Attach
</a>

修改

我删除了模式并仅使用了ng-click并尝试了,但是每次点击都会得到true / false。但我的<div>不可见。

{{showDetails}}
<div class ="bar bar-footer" ng-show="showDetails" >
<div class = "tabs tabs-icon-bottom tabs-striped tabs-color-gray hide-on-keyboard-open"  style="background-color: white;" >
 <a class = "tab-item" ng-click="myCam()">
   <i class = "icon  ion-camera"></i>
     Camera
 </a>

<a class = "tab-item" ng-click="pdfUpload()">
   <i class = "icon ion-upload"></i>
     Pdf
</a>

  

任何人都可以帮助我。

2 个答案:

答案 0 :(得分:2)

ng-click="show = ! show"将是您需要附加到点击事件或图标的内容。 ng-show="show"是显示和隐藏在DOM上的内容。

  <a class = "tab-item" ng-click="show = ! show">
   <i class = "icon  ion-paperclip"></i>
     Attach
  </a>

<div class ="bar bar-footer" ng-show="show">
 <div class = "tabs tabs-icon-bottom tabs-striped tabs-color-gray hide-on-keyboard-open" style="background-color: white;" >
<a class = "tab-item" ng-click="myCam()">
   <i class = "icon  ion-camera"></i>
     Camera
</a>

<a class = "tab-item" ng-click="pdfUpload()">
   <i class = "icon ion-upload"></i>
     Pdf
</a>

我希望这个答案对你来说已经足够了。这是一个小提琴Fiddle Link

答案 1 :(得分:1)

更新小提琴链接

Updated Fiddle

控制器代码

var SampleApp;
(function (SampleApp) {

var app = angular.module('sampleApp', ['ionic']);    
app.controller('MainCtrl', function ($scope) {



    $scope.toggleStretchedMode = function() {

    $scope.showDetails= !$scope.showDetails;



  }

});

})(SampleApp || (SampleApp = {}));

Html代码

<div>       
    <div ng-app="sampleApp" ng-controller="MainCtrl">
         <ion-content style="display:block">
         <div class="row" ng-if="showDetails"  style="padding-left: 205px;padding-top: 128px;">
        <div class="col col-33" style="text-align:center;">
          <ul class="row" >
            <li class="col" style=" display:inline;padding: 10px 15px;">
            <a class = "tab-item" ng-click="myCam()">
            <i class = "icon  ion-camera"></i>
             Camera
            </a></li>
             <li class="col" style=" display:inline;padding: 10px 15px;" >
            <a class = "tab-item" ng-click="myCam()">
            <i class = "icon  ion-camera"></i>
             Gallery
            </a></li>
            <li class="col" style=" display:inline;padding: 10px 15px;">
            <a class = "tab-item" ng-click="pdfUpload()">
            <i class = "icon ion-upload"></i>
              Pdf
    </a></li>


          </ul>
        </div>
      </div>

        </ion-content>

        <div class ="bar bar-footer">
  <div class = "tabs tabs-icon-bottom tabs-striped tabs-color-gray hide-on-keyboard-open" style="background-color: #11c1f3;">
    <a class = "tab-item" ui-sref="app.homeApp">
       <i class = "icon ion-home"></i>
     Home
    </a>

    <a class = "tab-item" ng-click="myCam()">
       <i class = "icon  ion-camera"></i>
         Camera
    </a>

    <a class = "tab-item" ng-click="toggleStretchedMode()">
       <i class = "icon  ion-paperclip"></i>
         Attach
    </a>

   </div>
</div>

    </div>     
</div>

希望有所帮助