我有下一个html代码:
<div class="collapse navbar-collapse menu-sidebar">
<ul class="nav nav-stacked" id="menu-bar">
<li class="panel dropdown" ng-repeat="m in menuSidebar.links">
<a data-toggle="collapse" data-parent="#menu-bar" data-target="#{{'menuSidebar' + $index}}" href="">
{{m.text}}
</a>
<div id="{{'menuSidebar' + $index}}" class="panel-collapse collapse submenu-sidebar">
<ul class="nav nav-stacked">
<li ng-repeat="s in m.sub" ng-class="{active: s.active}"><a href="{{s.link}}">{{s.text}}</a></li>
</ul>
</div>
</li>
</ul>
</div>
下一个json:
$scope.menuSidebar = {
"links": [
{
"text": "Total",
"sub": [
{
"active": true,
"link": "#",
"text": "General"
},
{
"active": false,
"link": "#",
"text": "Cargos"
},
{
"active": false,
"link": "#",
"text": "Prestadora"
},
{
"active": false,
"link": "#",
"text": "Factura"
}
]
},
{
"text": "Departamento",
"sub": [
{
"active": false,
"link": "#",
"text": "Costos"
},
{
"active": false,
"link": "#",
"text": "Tiempos"
}
]
}
]
};
我想在任何孩子是active==true
.
<div id="{{'menuSidebar' + $index}}" ng-class="active: ..." class="panel-collapse collapse submenu-sidebar">
如何遍历所有孩子并确定班级?在这种情况下可以使用 ng-class 吗?
谢谢