Reputation: 98
I am using angular uib-accordion and my accordion-group is populated dynamically using ng-repeat like this
<uib-accordion id="customer-details">
<uib-accordion-group ng-repeat="task in ctrl.results | toArray | orderBy:ctrl.orderByFunction" ng-click="ctrl.select(task, $index)">
<uib-accordion-heading >
</uib-accordion-heading>
<uib-accordion-group>
my question is how can I make this accordion to show only the active group and rest to hide completely .Also the active group needs to take the whole height of the accordion and toggling should come back to the normal state( of course toggling happens with the help of a button like + and -).
Upvotes: 0
Views: 663
Reputation: 1907
use this :
<ul data-ui-sref-active="active" > ... </ul>
Add following method in your controller:
$scope.opened = false;
$scope.toggle = function () {
$scope.opened = !($scope.opened);
};
Then call toggle
method in html :
ng-click="toggle()"
Upvotes: 1
Reputation: 3104
You can add an ng-if
directive to the repeated group element (I'm assuming each task has an active
property):
<uib-accordion-group ng-repeat="task in ctrl.results | toArray | orderBy:ctrl.orderByFunction"
ng-click="ctrl.select(task, $index)"
ng-if="task.active">
<uib-accordion-heading >
</uib-accordion-heading>
<uib-accordion-group>
Here's the ng-if
documentation: https://docs.angularjs.org/api/ng/directive/ngIf
Upvotes: 0