你好我想切換一個特定的面板,但如果我點擊按鈕,其他對象的面板將被打開。我怎樣才能打開點擊面板?在ngFor循環中只切換一個特定的面板
toggle.component.ts
opened:Boolean=false;
toggle() {
this.opened = !this.opened;
}
HTML
<div class="main" *ngFor="let x of data; let i=index;">
<footer>
<div class="icons">
<span id="{{item.id}}" (click)="toggle()">6<i class="fa fa-users {{i}}" ></i></span>
<span >6<i class="glyphicon glyphicon-picture"></i></span>
<span >6<i class="glyphicon glyphicon-tag"></i></span>
<div class="iconsRight pull-right">
<span >EXIF<i class="glyphicon glyphicon-info-sign"></i></span>
<span ><i class="fa fa-map-marker"></i></span>
<span ><i class="fa fa-share-alt-square"></i></span>
</div>
</div>
</footer>
<div class="togglePanel{{item.id}}" *ngIf="opened" >
<hr/>
<ul class="toggleWrapper">
<li>YES</li>
<hr/>
<li>YES</li>
<hr/>
<li>YES</li>
<hr/>
<li>YES</li>
</ul>
</div>
</div>
沒問題,但請參閱上面的圖片。右側的面板也被打開。沒有內容 –
你做了什麼改變? – Faisal
好的,對不起,我的錯誤。我在工作人員周圍有一個包裝div –