app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
isExpansionPanelOpened = false;
onOpened(){
this.isExpansionPanelOpened = true;
}
onClosed(){
this.isExpansionPanelOpened = false;
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - Expansion Panel opened and closed event
</h2>
<h3>
Expansion Panel : {{isExpansionPanelOpened? 'Opened' : 'Closed'}}
</h3>
<mat-expansion-panel (opened)="onOpened()" (closed)="onClosed()">
<mat-expansion-panel-header>
<mat-panel-title>Android</mat-panel-title>
<mat-panel-description>
I am {{isExpansionPanelOpened? 'opened' : 'closed'}}.
</mat-panel-description>
</mat-expansion-panel-header>
Content: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque nec bibendum ligula. Pellentesque imperdiet
non massa at sodales. Cras nibh elit, iaculis id semper in,
euismod eu ante. Morbi ac massa pellentesque, porta
velit sed, elementum ipsum. Duis sed risus sit amet tellus
euismod consequat sed a ante. Lorem ipsum dolor
sit amet, consectetur adipiscing elit.
</mat-expansion-panel>
app.module.ts [import]
import {MatExpansionModule} from '@angular/material/expansion'
- angular material - Tick interval with step in Slider
- angular material - How to invert Slider
- angular material - How to show thumb label in Slider
- angular material - How to use Slider input event
- angular material - How to use Slide toggle
- angular material - How to change Slide toggle checked color
- angular material - How to use Badge with text
- angular material - How to change Badge position
- angular material - How to toggle Badge visibility
- angular material - How to use Accordion
- angular material - How to use Expansion Panel
- angular material - Action bar inside an Expansion Panel
- angular material - Icon inside Expansion Panel header
- angular material - Show Accordion toggle icon on left
- angular material - Open & close Accordion all panels at once