【发布时间】:2015-02-02 03:08:54
【问题描述】:
我想要一个下拉列表 select 和 option 显示一棵树,其中子项是缩进的,因此对用户来说很明显它们是子项。当我运行它时,select 中几乎没有显示任何内容。理想情况下,我希望它显示like this
我的第二个问题是在选项中使用填充不起作用我必须使用 ,但是如何将嵌套信息传递到模板中以输出所需数量的空格?
<script type="text/ng-template" id="tree_option_renderer.html">
<option>{{data.Name}}</option>
<!-- Would want 1 per level to indent properly, how? -->
<option ng-repeat="data in data.Children" ng-include="'tree_option_renderer.html'">
</script>
<select id="folderList" ng-show="operatesOnSelector == 0">
<option ng-repeat="group in addressbook" ng-include="tree_option_renderer.html"></option>
</select>
我的数据看起来有点像这样:
{
Id: 0,
Name: "Level 1",
Children: [
{
Id: 1,
Name: "level 2",
Children: []
}
]
}
【问题讨论】:
-
<select>不支持嵌套的 optgroups -
否,但您可以使用 缩进
-
对...那么,你为什么有
<div>呢? -
如果您阅读我的评论,我不知道如何在 Angular 中执行
&nbsp;的内容,div 是我最初的尝试,我提供的 jsFiddle 用&nbsp;显示它 - 我会更新我的问题更清楚 -
啊,没注意到编辑
标签: angularjs select tree option