I have a problem with using bootstrap collapse ui with angularJs. When I click on arrow button, it's collapsing all items(divs) instead of one. Could any body help me please how can I define selected item(div) to be collapsed instead of all? Here's my code.Thanks.
<div class="panel">
<div class="panel-header">
<div class="panel-header-info">
<div class="items_list" *ngFor="let item of items">
<div class="items_arrow_button" (click)="isCollapsed = !isCollapsed">
<div class="img">
<img src="./assets/images/img.png" class="img-responsive">
</div>
<span> Test data {{data.data}}</span>
<i class="fa" [ngClass]="{'fa-angle-down': isCollapsed, 'fa-angle-up': !isCollapsed}"></i>
</div>
<div class="items_list" [collapse]="isCollapsed">
<ul>
<li>
<h2>First item</h2>
<span>{{data.item}}</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
Its because isCollapsed
is the only basis that your collapsible have. Add isCollapsed
as a property in your item
. and then use item.isCollapsed
for the collapse toggle.
You are using the same variable for each item.
To solve your problem, you can:
isCollapse
in the item
variable but you have to update your model to store a context variable array
of N elements and you handle each state in this array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.