简体   繁体   中英

Open mat-expansion-panel ONLY when button is clicked

Is there a way in which I can make my mat-expansion-panel open ONLY WHEN I click a certain button?

I am thinking of having a list of info that I can click an edit icon on, which would cause the expansion to happen revealing the edit options...

Of course, I do not want the panel to expand when clicking randomly on the row, but only on the edit icon...

you need to add to your styles.css file the following code:

span.mat-expansion-indicator
{
   pointer-events: visiblefill !important; 
}

mat-expansion-panel-header 
{
   pointer-events: none;
}

#HTML CODE:

<mat-expansion-panel [expanded]="panelOpenState">

<mat-expansion-panel-header>
    <mat-panel-title>
        Edit
    </mat-panel-title>
</mat-expansion-panel-header>
<p>Edit Body</p>
</mat-expansion-panel>

<button (click)="togglePanel()">Edit</button>

#TS CODE:

panelOpenState: boolean = false;

togglePanel() {
this.panelOpenState = !this.panelOpenState
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM