Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
198
rated 0 times [  199] [ 1]  / answers: 1 / hits: 15888  / 11 Years ago, tue, february 18, 2014, 12:00:00

I am trying to embed some collapsible panels in a ngRepeat.
This is what I have:


<div class="panel panel-default" ng-repeat="element in elements">
<div class="panel-heading">
{{element.name}}
<button value="Collapse" ng-click="element.isCollapsed != element.isCollapsed"></button>
</div>
<div class="panel-body" collapse="element.isCollapsed">
Content
</div>
</div>

Now, when I click on the button, the collapse doesn't work.


From the documentation I understand that the repeater creates a scope for every element.


And the attribute collapse of the panel-body should get the same scope, right?


It seems that the scope.$watch in the collapse directive is not working properly.


More From » angularjs

 Answers
15

Please check the updated fiddle: http://jsfiddle.net/nZ9Nx/9/



I have created the app and injected ui-bootstrap in it to have the collapse working.



angular.module('test', ['ui.bootstrap']);

[#72465] Monday, February 17, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sidneyh

Total Points: 118
Total Questions: 108
Total Answers: 105

Location: Mali
Member since Fri, Jun 18, 2021
3 Years ago
sidneyh questions
Tue, Jun 7, 22, 00:00, 2 Years ago
Wed, Apr 13, 22, 00:00, 2 Years ago
Wed, Aug 12, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Fri, Apr 24, 20, 00:00, 4 Years ago
;