AngularJs:嵌套 UI-Bootstrap 手风琴在更新列表值时不起作用
AngularJs: Nested UI-Bootstrap accordion not working, when update list value
我通过 ng-repeat
生成 "ui-bootstrap accordion"。我想动态更新列表的值。但是当我更新嵌套列表值时,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
不工作。
add ng-click="getBanks(prInfo)"
to first accordion:
<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
此更改后,嵌套手风琴不工作,第一个手风琴不打开,第二个手风琴不生成。
如果我将所有手风琴设置为打开,两个手风琴都可以正常工作,但是当我想打开其中一个时,问题又出现了。
我用 bootstrap 手风琴来做这个,但又遇到了这个问题。
我分两步解决了问题,
首先将 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>
我通过 ng-repeat
生成 "ui-bootstrap accordion"。我想动态更新列表的值。但是当我更新嵌套列表值时,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
不工作。
add
ng-click="getBanks(prInfo)"
to first accordion:
<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
此更改后,嵌套手风琴不工作,第一个手风琴不打开,第二个手风琴不生成。
如果我将所有手风琴设置为打开,两个手风琴都可以正常工作,但是当我想打开其中一个时,问题又出现了。
我用 bootstrap 手风琴来做这个,但又遇到了这个问题。
我分两步解决了问题,
首先将 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>