问题
In AngularJS I am using a bootstrapUI accordion directive that contains a nested accordion in one of the panes.
When I close the 'parent' I would like to close its 'children'. I am having trouble because the accordion directive uses transclusion, and the scopes are actually siblings not parent to child.
<div ng-controller="AccordionDemoCtrl">
<accordion close-others="oneAtATime">
<accordion-group heading="Static Header">
This content is straight in the template.
</accordion-group>
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</accordion-group>
<accordion-group heading="Nested Accordian">
<accordion close-others="oneAtATime">
<accordion-group heading="Static Header">
This content is straight in the template.
</accordion-group>
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</accordion-group>
</accordion>
</accordion-group>
</accordion>
</div>
Plunker demo
回答1:
Have you tried changing close-others= true;
来源:https://stackoverflow.com/questions/20753595/close-nested-ui-bootstrap-accordion-when-parent-closes