There 3 records fetch by query and since I using iterator It shows 3 buttons as well whenever I click any show button it expands all 3 records I just wanted to expand only that record which button I clicked How should I do that?
<template>
<div class="lightningcard">
<lightning-card>
<template if:true={Announcements.data}>
<template for:each={Announcements.data} for:item="Announcement__c">
<p key={Announcement__c.Id} class="description"><b>{HSOP_Announcement__c.Name}</b></br></p>
<template if:true={boolVisible}>
<span class={showMoreClass} key={Announcement__c.Id}>{Announcement__c.AnnouncementDescription__c}</span>
</template>
<lightning-button key={Announcement__c.Id} variant="brand" label={clickedButtonLabel} title="...more" onclick={handleClick} class="slds-m-left_x-small"></lightning-button>
</template>
</template>
</lightning-card>
</div>
</template>
JavaScript
@wire(announcementlist)
Announcements;
@track clickedButtonLabel = 'Show';
@track boolVisible = false;
handleClick(event) {
const label = event.target.label;
const annoucement = this.template.querySelector('p').key;
if ( label === 'Show' ) {
this.clickedButtonLabel = 'Hide';
this.boolVisible = true;
} else if ( label === 'Hide' ) {
this.clickedButtonLabel = 'Show';
this.boolVisible = false;
}