![](/img/trans.png)
[英]Material UI- My Card Component is getting added to my Appbar. I want the cards to show up once a button the Appbar is clicked
[英]I want my button to hide and show only the contents of the card I clicked on not without affecting the others
假設你的卡片是一個數組,這可能是這樣的:
成分:
class MyComponent {
data: [{
label: 'First',
items: [{name: 'name'}, {name: 'name'}, {name: 'name'}],
isOpen: false
}, {
label: 'Second',
items: [{name: 'Time'}, {name: 'Time'}, {name: 'Time'}],
isOpen: false
}, {
label: 'Third',
items: [{name: 'baby'}, {name: 'baby'}, {name: 'baby'}],
isOpen: false
}]
}
toggleCard(card) {
card.isOpen = !card.isOpen;
}
<div class="cards" *ngFor="let card of data">
<div class="card-header" (click)="toggleCard(card)">
</div>
<div class="card-content" *ngIf="card.isOpen">
</div>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.