我正在尝试从包含嵌套数据的对象中创建一个多级列表:
function linksRarrange($scope) {
$scope.links = [
{
text: 'Menu Item 1',
url: '#',
},{
text: 'Menu Item 2',
url: '#',
submenu: [
{
text: 'Sub-menu Item 3',
url: '#',
},{
text: 'Sub-menu Item 4',
url: '#',
submenu: [
{
text: 'Sub-sub-menu Item 5',
url: '#',
},{
text: 'Sub-sub-menu Item 6',
url: '#',
}
]
}
]
},{
text: 'Menu Item 3',
url: '#',
}
];
}
为什么这仅输出前 2 级菜单而忽略第三级?
<ul>
<li ng-repeat="link in links"><a href="{{link.url}}">{{link.text}}</a>
<ul>
<li ng-repeat='sublink in link.submenu'><a href="{{sublink.url}}">{{sublink.text}}</a></li>
</ul>
</li>
</ul>