首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >html表中的AngularJS递归

html表中的AngularJS递归
EN

Stack Overflow用户
提问于 2015-09-18 00:04:15
回答 2查看 258关注 0票数 0

好的,我有这个代码:

代码语言:javascript
复制
        <table class="table">
            <thead>
            <tr>
                <th>
                    Description
                </th>
                <th>
                    Amount
                </th>
                <th>
                    Period
                </th>
            </tr>
            </thead>
            <tbody data-ng-repeat="expense in expenses">
            <tr class="danger">
                <td>
                    <button data-ng-if="expense.Children.length > 0 && expense.ShowChildren" type="button" class="btn btn-default btn-sm" ng-click="expense.ShowChildren = false">
                        <span class="glyphicon glyphicon-minus" aria-hidden="true" ></span>
                    </button>
                    <button data-ng-if="expense.Children.length > 0 && !expense.ShowChildren" type="button" class="btn btn-default btn-sm" ng-click="expense.ShowChildren = true">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                    </button>
                    {{ expense.Description }}
                </td>
                <td>
                    {{ expense.Amount }}
                </td>
                <td>
                    {{ expense.Period }}
                </td>
            </tr>
            <tr class="active" ng-show="expense.ShowChildren" data-ng-repeat="child in expense.Children">
                <td>
                    &emsp;&ensp;&emsp;&ensp;{{ child.Description }}
                </td>
                <td>
                    &emsp;&ensp;&emsp;&ensp;{{ child.Amount }}
                </td>
                <td>
                    &emsp;&ensp;&emsp;&ensp;{{ child.Period }}
                </td>
            </tr>
            </tbody>
        </table>

现在我想花钱可以有一个像你在照片中看到的孩子,这是工作,但是当孩子有了孩子,我怎么展示呢?我想做加号/减号按钮

EN

回答 2

Stack Overflow用户

发布于 2015-09-18 00:08:42

我最近一直在用泳道的桌子,效果很好。这是他们支持的一个特性。此表可在此处查看。

http://swimlane.github.io/angular-data-table/

您可以这样做,但基本上必须使用在适当位置插入按钮的表达式和ng-show/css在按钮被单击时隐藏和显示行,以及许多其他手动工作。

票数 0
EN

Stack Overflow用户

发布于 2015-09-18 06:00:46

我找到了一种简单的方法

代码语言:javascript
复制
Tree View: http://jsfiddle.net/brendanowen/uXbn6/8/

它比其他方法更好,也更简单

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32635009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档