【问题标题】:Close nested UI Bootstrap accordion when parent closes父关闭时关闭嵌套的 UI Bootstrap 手风琴
【发布时间】:2013-12-24 01:23:55
【问题描述】:

在 AngularJS 中,我使用了一个 bootstrapUI 手风琴指令,该指令在其中一个窗格中包含一个嵌套手风琴。

当我关闭“父级”时,我想关闭它的“子级”。我遇到了麻烦,因为手风琴指令使用了嵌入,而作用域实际上是兄弟姐妹而不是父子关系。

<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

【问题讨论】:

  • 我获取了 bootstrapUI 源并对其进行了扩展,以通过 'id' 元素属性跟踪 rootScope 中的继承。这感觉不像是“角度方式”,所以我仍然对另一种方法感兴趣。

标签: angularjs accordion directive transclusion


【解决方案1】:

您是否尝试过更改 close-others= true;

【讨论】:

    猜你喜欢
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多