I have implemented this accordion component:
<uib-accordion close-others="true">
<uib-accordion-group heading="Action" is-open="true" class="text-center">
<div class="btn-group text-center" data-toggle="buttons" >
<button type="button" class="btn"
ng-repeat="action in actions" ng-model="$parent.selectedAction" uib-btn-radio="action"
ng-class="{'btn-danger custom-btn-danger': $index == 0, 'btn-success custom-btn-success': $index == 1}" >
{{action.text}}
</button>
</div>
{{selectedAction}}
</uib-accordion-group>
<uib-accordion-group heading="Confirm" is-open="true">
<div ng-if="selectedAction.value == 'reject'">
Comments
<br />
<textarea cols="30" rows="5"></textarea>
<br />
<br />
<div class="text-center">
<input type="button" value="Reject" class="btn btn-danger active" />
</div>
</div>
<div ng-if="selectedAction.value == 'approve'">
<div class="text-center">
<div class="btn-group btn-group-vertical" data-toggle="buttons">
<button type="button" class="btn btn-primary custom-btn-primary"
ng-repeat="item in items" ng-model="$parent.selectedProcessLevel" uib-btn-radio="item"
ng-style="roundTopRight($index)">{{item.text}}</button>
</div>
</div>
<br />
Comments
<br />
<textarea cols="30" rows="5"></textarea>
<br />
<br />
<div class="text-center">
<input type="button" value="Approve" class="btn btn-success active" />
</div>
</div>
</uib-accordion-group>
</uib-accordion>
Along with the following JavaScript code:
$scope.selectedAction = { value: 'approve', text: 'Approve', isOpen: false };
$scope.actions = [
{ value: 'reject', text: 'Reject', isOpen: true },
{ value: 'approve', text: 'Approve', isOpen: false },
];
$scope.selectedProcessLevel = { value: '2lp', text: '2 Level Process' };
$scope.processLevels = [
{ value: '1', text: 'One' },
{ value: '2', text: 'Two' },
{ value: '3', text: 'Three' },
];
$scope.roundTopRight = function (index) {
if (index == 0)
return { 'border-top-right-radius': '4px' };
}
I am trying to dynamically change the content of the second accordion group by clicking on the reject or approve buttons. Previously, I had a simple table which worked perfectly before implementing the UI Bootstrap accordion component.
Could there be a scope-related issue causing this behavior?
Additionally, how can I automatically collapse the action group and expand the confirm group by clicking on one of the buttons?
Thank you for your help.