1
當我點擊任何摺疊切換圖標,它只適用於ng-repeat
生成的第一個li
,我該如何解決這個問題,所以它只能摺疊它的父母li
?我如何使Bootstrap崩潰與嵌套的AngularJS NG重複正常工作?
$scope.data = [{
label: 'North America',
children: [{
label: 'Canada',
children: ['Toronto', 'Vancouver']
}, {
label: 'USA',
children: ['New York', 'Los Angeles']
}, {
label: 'Mexico',
children: ['Mexico City', 'Guadalajara']
}]
}, {
label: 'South America',
children: [{
label: 'Venezuela',
children: ['Caracas', 'Maracaibo']
}, {
label: 'Brazil',
children: ['Sao Paulo', 'Rio de Janeiro']
}, {
label: 'Argentina',
children: ['Buenos Aires', 'Cordoba']
}]
}];
<ul class="list-group">
<li class="list-group-item" ng-repeat="item in data">
<ul class="collapse in" ng-if="item.children" id="collapse">
<i class="glyphicon glyphicon-minus pull-right" data-toggle="collapse" data-target="#collapse"></i>
<i class="glyphicon glyphicon-plus pull-right hidden"></i>
{{item.label}}
<li class="list-group-item" ng-repeat="sub in item.children">
{{sub.label}}
</li>
</ul>
</li>
</ul>
完美工作,th ank you for clear answer – klferreira
沒問題,很高興幫助。 :) –
節省了我幾個小時的調試時間。 :)謝謝@MatthewCawley – yeaske