[英]how to create a button when the first element is clicked it should hide and show second element using ng-show/ng-hide 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>
您可以嘗試以下操作,以在元素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>
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.