javascript - Toggle a div in Angular -
how can make toggle in angular.js div open , close when clicked on same div again. perfoms action opens div whenever click again on it, div needs close again.
<a ng-href ng-click="openaccordionrow(champion.clean)"> zerg </a>
and opens:
<div ng-show="isaccordionopen(champion.clean)"> info </div>
js:
$scope.activerows = ""; $scope.isaccordionopen = function(row) { if ($scope.activerows === row) { return true; } else { return false; } } $scope.openaccordionrow = function(row) { $scope.activerows = row; }
problem here same clicked div doesn't close when pressing on again.
currently code doesn't have attempts collapse row. change code this.
html:
<a ng-href ng-click="toggleaccordionrow(champion.clean)"> zerg </a>
javascript:
$scope.activerows = ""; $scope.isaccordionopen = function(row) { if ($scope.activerows === row) { return true; } else { return false; } } $scope.toggleaccordionrow = function(row) { $scope.activerows = $scope.isaccordionopen(row) ? "" : row; }
Comments
Post a Comment