如何在单击第一个元素时创建一个按钮,它应该隐藏并使用ng-show / ng-hide angularjs显示第二个元素?

问题描述 投票:0回答:2

请帮助,如何在点击第一个元素时进行显示/隐藏,第一个元素将通过使用angularjs ng-show / ng-hide更改为第二个元素?

<div class="panel panel-default" ng-click="showDetails1 = !showDetails1">
     <div ng-show="showDetails1">
          //this is element 1
     </div>
     <div ng-click="showDetails2 = !showDetails2">
          <div ng-show="showDetails2">
              //this is the second element that will appear when the first element is clicked
          </div>
     </div>
</div>
javascript jquery angularjs
2个回答
0
投票

您可以尝试以下操作,以在隐藏元素1时显示元素2,并在隐藏元素2时显示元素1。

   <div class="panel panel-default" ng-init="showDetails =true" ng-click="showDetails = !showDetails">
         <div ng-show="showDetails">
              //this is element 1
         </div>
         <div ng-show="!showDetails">
              //this is the second element that will appear when the first element is clicked
         </div>
    </div>

0
投票
<div class="panel panel-default" ng-click="showDetails1 = !showDetails1">
     <div ng-show="showDetails1">
          //this is element 1
     </div>
     <div ng-hide="showDetails1">
          //this is the second element that will appear when the first element is clicked
      </div>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.