【问题标题】:Mixing a Table with Angular-UI Accordion将表格与 Angular-UI 手风琴混合
【发布时间】:2014-12-22 16:50:48
【问题描述】:

我正在尝试将一张桌子与 angular-ui 的手风琴混合,但我想不出办法。 我不是专业人士,写指令。我想知道这样的桥是否存在。要实现这样的目标:

<table class="table table-hover table-condensed" thead>
    <thead>
        <tr>
            <th>{{ data.profile.firstname }}</th>
            <th>{{ data.profile.lastname }}</th>
            <th>{{ data.profile.email }}</th>
            <th>{{ data.profile.company_name }}</th>
            <th>{{ data.profile.city }}</th>
        </tr>
    </thead>
    <tbody accordion close-others="true">
        <!-- <tr ng-repeat="client in clients" ng-click="goTo('profile/' + client.username);"> -->
        <tr ng-repeat="client in clients" accordion-group is-open="client.isOpen">
            <accordion-heading>
                <td>{{ client.firstname }}</td>
                <td>{{ client.lastname }}</td>
                <td>{{ client.email }}</td>
                <td>{{ client.company_name }}</td>
                <td>{{ client.city }}</td>
            </accordion-heading>
            Accordion Content
        </tr>
    </tbody>
</table>

虽然它不起作用:(有没有人成功实现了这样的目标?

我正在寻找的结果是,当我单击表格中的一行时,它的行为与手风琴相同。

【问题讨论】:

    标签: angularjs css angular-ui-bootstrap


    【解决方案1】:

    在我的情况下,我让它有点原始,但也许这对你来说也是一个很好的解决方案。看:

     <tbody ng-repeat="person in people | orderBy:predicate:reverse"  >
      <tr ng-click="isOpen=!isOpen">
        <td>{{person.name}}</td>
        <td>{{person.job}}</td>
        <td>{{person.age}}</td>
        <td>{{person.grade}}</td>
      </tr>
      <tr ng-if="isOpen">
      <td>Just an empty line</td>
      </tr>
      </tbody>
    

    【讨论】:

    • 为了确保一次只有一个手风琴保持打开状态,请在您的 Ctrl 中声明这一点(受 Mohideen ibn Mohammed 下面的启发): $scope.expanded = {l1: -1};然后你可以做这样的事情(你可以使用 l2 等其他级别): {{person.name}} {{person.job}} {{person. age}} {{person.grade}} 只是一个空行
    【解决方案2】:

    1) 您可以尝试使用div 代替table 主手风琴。它对我有用。

    2) 下面是在 JSFiddle 中完成的 accordion table 示例,希望对您有所帮助。 http://jsfiddle.net/Pixic/VGgbq/

    【讨论】:

    • 通常不鼓励在堆栈溢出答案中没有解释的外部站点链接。在这里用相关的sn-ps代码解释解决方案。链接到小提琴作为一种查看它的方式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-11
    • 2016-06-13
    • 1970-01-01
    相关资源
    最近更新 更多