Angulejs UI crashes in ngRepeat

I am trying to embed some interchangeable panels in 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 crash is not working. From the documentation, I understand that a repeater creates an area for everyone element. And the collapsepanel-to-panel attribute should get the same amount, right? The directive scope.$watchin the directive seems to be collapseworking incorrectly. Or maybe I'm doing something wrong?

thanks

+4
source share
2 answers

Check the updated script: http://jsfiddle.net/nZ9Nx/9/

I created an application and injected ui-bootstrap into it to minimize the work.

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

<div class="panel-heading" toggle target="collapseOne">

. ...

<div class="panel-heading" toggle target="collapse{{ $index + 1 }}">

<div id="collapse{{ $index + 1 }}" toggleable active-class="in" exclusion-group="accordion1" default="active" class="panel-collapse collapse">

<div ng-repeat="item in awesomeThings">
    <div class="panel panel-default">
        <div class="panel-heading" toggle target="collapse{{ $index + 1 }}">
            <h4 class="panel-title">
                {{ item }}
            </h4>
        </div>
        <div id="collapse{{ $index + 1 }}" toggleable active-class="in" exclusion-group="accordion1" default="active" class="panel-collapse collapse">
            <div class="panel-body">
                <!-- ... -->
            </div>
        </div>
    </div>
</div>
+3

Source: https://habr.com/ru/post/1527485/


All Articles