Close a Collapse when opening another using Angularjs UI

Asked

Viewed 460 times

2

I have one Collapse and the other right next, I wanted to click on one, close the other if it was open.

My html code:

angular.module("seuCondominio", ['ui.bootstrap']);
angular.module("seuCondominio").controller("seuCondominioCtrl", function($scope) {
  $scope.isCollapsed = true;
  $scope.isCollapsededit = true;
  $scope.tarefas = [{
    id: 0,
    nome: "Lavar alguma coisa",
    inicio: "10/10/10",
    conclusao: "11/10/10",
    custo: "1000",
    status: {
      nome: "Concluído"
    }
  }]
});
<html ng-app="seuCondominio">

<head>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.js"></script>
  <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
  <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>

<body ng-controller="seuCondominioCtrl">

  <div id="editar">
    <button id="lapis" class="btn btn-default" ng-click="isCollapsededit = !isCollapsededit">Simbolo</span>
    </button>

    <button class="btn btn-default" ng-click="isCollapsed = !isCollapsed"><span class="glyphicon glyphicon-chevron-right"></span>{{' ' + tarefas[0].nome}}</button>
    <div collapse="isCollapsededit" style="position:relative">
      Conteudo 1
    </div>
  </div>
  <div collapse="isCollapsed" style="position:relative">
    Conteudo 2
  </div>
  </div>

</html>
</body>
So I wanted, somehow, when I clicked on one, the other to close.

1 answer

0


I found that I can use more than one ng-click command using ";", so I put

ng-click="acc1 = !acc1; acc2 = true

and

ng-click="acc2 = acc2; acc1 = true

in the Buttons and it worked

was worth Grl ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.