angularjs嵌套手风琴关闭 - 其他不工作

时间:2015-03-06 20:16:48

标签: angularjs twitter-bootstrap nested accordion

我使用“accordion”和“accordion-group”标签在angularJS上有一个多级手风琴。我在父手风琴中使用close-others="false",在嵌套手风琴中使用close-others="true"

而不是外部面板允许多个组展开而内部面板只允许一个的预期行为,我所看到的是父面板和子面板允许一次打开多个组。

<accordion close-others="false">
  <!-- Outer Group #1 -->
  <accordion-group heading="Outer Group #1" ng-init="status.isOuterGroup1Open = true" 
       is-open="status.isOuterGroup1Open">
    <!-- Outer Content Here -->
  </accordion-group>

  <!-- Outer Group #2 -->
  <accordion-group heading="Outer Group #2" ng-init="status.isOuterGroup2Open = true" 
       is-open="status.isOuterGroup2Open">
    <accordian close-others="true">
      <!-- Inner Groups -->
      <accordion-group data-ng-repeat="outerItem in outerItems" 
           heading="{{outerItem.name}}">
        <div data-ng-repeat="innerItem in outerItem.children">
          <!-- Inner content here -->
          {{innerItem.name}}
        </div>
      </accordion-group>
    </accordian>
  </accordion-group>
</accordion>

我有什么想法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:3)

在你的例子中,在'Outer Group#2'中你有'accordian',它应该是'accordion'。我认为这就是问题所在。这是带有应用修复的代码:

<accordion close-others="false">
  <!-- Outer Group #1 -->
  <accordion-group heading="Outer Group #1" ng-init="status.isOuterGroup1Open = true" 
       is-open="status.isOuterGroup1Open">
    <!-- Outer Content Here -->
  </accordion-group>

  <!-- Outer Group #2 -->
  <accordion-group heading="Outer Group #2" ng-init="status.isOuterGroup2Open = true" 
       is-open="status.isOuterGroup2Open">
    <accordian close-others="true">
      <!-- Inner Groups -->
      <accordion-group data-ng-repeat="outerItem in outerItems" 
           heading="{{outerItem.name}}">
        <div data-ng-repeat="innerItem in outerItem.children">
          <!-- Inner content here -->
          {{innerItem.name}}
        </div>
      </accordion-group>
    </accordian>
  </accordion-group>
</accordion>

如果更改不能解决行为问题,请发帖子吗?