我通过ng-repeat
生成“ui-bootstrap accordion”。我想动态列表的upddate值。但是当我更新嵌套列表值时,second accordion
无效。
<uib-accordion close-others="oneAtATime">
<uib-accordion-group heading="{{prInfo.name}}"
data-ng-repeat="(a,prInfo) in allPersonInfoNames | filter:prSearchFilter">
Below iss the inner accordion
<uib-accordion close-others="oneAtATime">
<uib-accordion-group heading="Static Payroll Header, inner accordion"
data-ng-repeat="(b,payroll) in prInfo.banks">
This content is straight in the template.
</uib-accordion-group>
</uib-accordion>
</uib-accordion-group>
<uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups1">
{{group.content}}
</uib-accordion-group>
</uib-accordion>
此代码工作正常,但在加载html后生成banks
列表时,accordion
无效。
将
ng-click="getBanks(prInfo)"
添加到第一支手风琴:
<uib-accordion-group heading="{{prInfo.name}}"
data-ng-repeat="(a,prInfo) in allPersonInfoNames | filter:prSearchFilter"
ng-click="getBanks(prInfo)">
$scope.getBanks = (personInfo) ->
$scope.prResPromise = Cartable.httpReq('GET', "getBanks/#{personInfo.dbId}", null, (res) ->
if res.isSuccess
pi = _.findWhere($scope.allPersonInfoNames, {'dbId' : personInfo.dbId})
index = $scope.allPersonInfoNames.indexOf(pi)
$scope.allPersonInfoNames[index] = res
在此更改后,嵌套式手风琴无法正常工作,第一个手风琴未打开,第二个手风琴不会产生。
如果我将所有accrotion设置为打开,两个手风琴都能正常工作,但是当我想打开其中一个时,问题再次出现。
我用bootstrap手风琴做这个,但又遇到了这个问题。
答案 0 :(得分:2)
我通过2步解决了这个问题,
首先将ui-bootstrap
的版本从0.3
更新为2.3.1
,然后为每个is-open
添加指定accordion
。
<uib-accordion close-others="oneAtATime1">
<div uib-accordion-group class="panel-default" is-open="prInfo.isOpen" heading="{{prInfo.name}}"
ng-repeat="prInfo in allPersonInfoNames">
<uib-accordion close-others="oneAtATime2">
<div uib-accordion-group class="panel-default" heading="{{payroll.logPeriod.name}}"
is-open="payroll.isOpen"
ng-repeat="payroll in prInfo.payrolls">
<div class="row">
<div class="col-md-4">
<h1>in nested accordion</h1>
</div>
</div>
</div>
</uib-accordion>
</div>
</uib-accordion>