0
I’m a beginner in Angularjs, and I don’t know how to proceed in this case.
I know how to create a panel that can appear and disappear as a variable in the controller, like this:
<div class="toggle-box"> <div ng-click="visivel = !visivel"> Clica! </div> <div ng-show="visivel"> Eu só vou aparecer quando visivel === true </div> </div>
Only I don’t know how to do this when there is only one panel. But what if there are multiples?
For example, how could I do all the div.toggle-box
have this function of switching visibility?
<div class="toggle-box"> <div ng-click="visivel = !visivel"> Primeiro painel </div> <div ng-show="visivel"> Eu só vou aparecer quando visivel === true </div> </div> <div class="toggle-box"> <div ng-click="visivel = !visivel"> Segundo painel </div> <div ng-show="visivel"> Eu só vou aparecer quando visivel === true </div> </div> ... <div class="toggle-box"> <div ng-click="visivel = !visivel"> Enésimo painel </div> <div ng-show="visivel"> Eu só vou aparecer quando visivel === true </div> </div>
In that case, the
div.toggle-box
disappeared after clicking on the panel, being impossible to make it visible again. And other, as there are severaldiv.toggle-box
, as soon as you click on the first one, the remaining ones would also disappear, since thevisivel
would becomefalse
...– Julio Hintze
You could put another div, or a boot to do it.
– Paulo Alexandre