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

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -