我是角度新人。所以我正在阅读写作只是为了完成我的工作。这样我会尝试,但不知道我是否在正确的方向?这里是我的示例代码如何使用ng-repeat以表格格式显示分层数据
<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重复表格输出。请看看这个网址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构建什么样的输出。
请指导和建议。
为什么负,当我展示我的努力。 – Mou
你必须去递归,所以你需要用ng-repeat注入DOM,而不是在DOM中写下你的ng-repeat作为声明 – Raffaeu
为什么不使用角度树视图。看到这个示例http://jsfiddle.net/eu81273/8LWUc/18/ –