我们有一个动态加载的Accordion Group,在点击标题时会填充子项内容。
一切正常,但我们似乎无法在点击下一个项目时关闭其他项目。
我们有close-others="true"
,数据结构正在ng-click
项上正确更新。
任何帮助?
这里是html
<accordion close-others="true" class="accordion">
<accordion-group heading="Team {{$index + 1}}"
ng-click="TabAction(tab.TeamRef, $index)"
ng-repeat="tab in Tabs" is-open="tab.IsOpen">
<div ng-repeat="t in tab.Team track by $index"
class="mf-custom-list-item">
</div>
</div>
</accordion-group>
</accordion>
这是管理On Click
值的tab.IsOpen
事件
$scope.TabAction = function (teamref, indx) {
let TabIndex = $scope.TabIndex;
if ($scope.Tabs[TabIndex].IsOpen && (TabIndex = indx)) {
$scope.Tabs[TabIndex].IsOpen = false;
} else {
// Only open a tab if it is different to that already open
$scope.Tabs[indx].IsOpen = true;
$scope.Tabs[TabIndex].IsOpen = false;
BidService.LoadBidTeam(teamref, indx, $scope);
}
$scope.TabIndex = indx;
$rootScope.app.appstate.Bid.Summary.TabIndex = indx;
};
答案 0 :(得分:0)
$scope.TabAction = function (teamref, indx) {
//close all tabs first
for(var i = 0, l = $scope.Tabs.length; i < l; i++){
$scope.Tabs[i].IsOpen = false;
}
let TabIndex = $scope.TabIndex;
$scope.Tabs[indx].IsOpen = true;
BidService.LoadBidTeam(teamref, indx, $scope);
$scope.TabIndex = indx;
$rootScope.app.appstate.Bid.Summary.TabIndex = indx;
};