使用角速度转动一个多维数组成多级列表 [英] Using angular to turn a multi-dimensional array into a multi level list
本文介绍了使用角速度转动一个多维数组成多级列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的角度JS和尝试使用NG-重复或类似的采取了多维数组,并把它放入DOM作为一座耗资级列表。
I am using Angular JS and trying to use ng-repeat or the like to take a multi-dimensional array and put it into the DOM as a mutli-level list.
从这个:
var menuOptions = [
["Page One"],
["Page Two"],
["Page Three"],
["Page Four", ["Sub-Page 1", "Sub-Page 2", "Sub-Page 3"] ],
["Page Five"]
];
这样:
<ul>
<li>Page One</li>
<li>Page Two</li>
<li>Page Three</li>
<li>Page Four
<ul>
<li>Sub-Page 1</li>
<li>Sub-Page 2</li>
<li>Sub-Page 3</li>
</ul>
</li>
<li>Page Five</li>
</ul>
我无法找到的角JS任何文件和搜索网页来到无济于事。我知道我能处理这样的事情用普通'醇的Javascript,或者PHP,但我想利用一些JS角一样的东西NG-重复。
I was unable to find anything in the Angular JS Documentation and a search of the web came to no avail. I am aware that I can handle something like this with plain 'ol Javascript, or PHP but I would like to utilize some Angular JS thing like ng-repeat.
任何输入AP preciated。
Any input is appreciated.
谢谢!
推荐答案
如果你把你的arraw这个:
If you turn your arraw into this:
var menuOptions = [
["Page One", []],
["Page Two", []],
["Page Three", []],
["Page Four", ["Sub-Page 1", "Sub-Page 2", "Sub-Page 3"] ],
["Page Five", []]
];
您应该能够做到这一点:
You should be able to do this:
<ul>
<li ng-repeat='option in menuOptions'>
{{option[Ø]}}
<ul>
<li ng-repeat='suboption in option[1]'>{{suboption}}</li>
</ul>
<li>
</ul>
这篇关于使用角速度转动一个多维数组成多级列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文