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

时间:2017-12-19 07:19:10

标签: javascript jquery angularjs

请帮助,如何在点击第一个元素时进行显示/隐藏,第一个元素将通过使用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>

2 个答案:

答案 0 :(得分:0)

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

s[i]--

答案 1 :(得分: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>