【发布时间】:2016-05-13 13:41:54
【问题描述】:
我是角度方面的新手。所以我正在阅读写作只是为了完成我的工作。这样我会尝试但不确定我是否朝着正确的方向前进?这是我的示例代码
<ul>
<li ng-repeat="parent in items">{{parent.pitem}}
<ul>
<li ng-repeat="child in parent.citems">{{child.pitem }}</li>
</ul>
</li>
</ul>
var app = angular.module('myapp', []);
app.controller('MyCtrl', function ($scope) {
$scope.items = [{ "pitem": "Coffee", "citems": "" }, { "pitem": "Tea", "citems": [{ "pitem": "Black tea", "citems": "" }, { "pitem": "Green tea", "citems": "" }] }, { "pitem": "Milk", "citems": "" }]
});
实际上我需要展示员工等级,例如经理及其下属。
我也在@zsong https://stackoverflow.com/a/18295177/6188148写的同一主题上阅读了这篇文章
所以请帮助我使用 ul,li 使用 ng-repeat 生成表格输出,最终用户也应该能够展开折叠行。请查看此 url http://maxazan.github.io/jquery-treegrid/examples/example-bootstrap-3.html 我想要类似的输出,但使用 ng-repeat。
看到这个 url http://www.lidorsystems.com/support/articles/angularjs/treegrid/tree-grid-filter.aspx 然后可以理解我想用 ng-repeat 构建什么样的输出。
请指导和建议。
【问题讨论】:
-
为什么当我表现出我的努力时是消极的。
-
你必须递归,所以你需要用 ng-repeat 注入 DOM,而不是在 DOM 中写下你的 ng-repeat 作为声明
-
为什么不使用角度树视图。查看此示例jsfiddle.net/eu81273/8LWUc/18
-
我想知道如何使用 ng-repeat 生成像树网格这样的输出。
标签: angularjs