Файл CSS: -
.zippy{
border: 1px solid #ccc;
border-radius:2px;
}
.zippy-heading{
font-weight: bold;
padding: 20px;
cursor: pointer;
background: #f09b9b;
}
.zippy-body{
padding: 20px;
}
.expanded{
background: #b3b0b0;
}
Просмотр HTML: -
<div class="zippy" style="padding:40px;">
<div class="zippy-heading"
[class.expanded]="isExpandedBikes"
(click)="onBikeClick()">
{{bike}}
<span
class="fa"
[class.fa-angle-down] ="!isExpandedBikes"
[class.fa-angle-up]="isExpandedBikes"
(click)="onBikeClick()" style="font-size: 20px; position: absolute;right: 50px;"></span>
</div>
<div *ngIf="isExpandedBikes" class="zippy-body">
<li *ngFor ="let data of bikeContent">
{{data}}
</li>
</div>
</div>
Файл компонента: -
constructor() {
this.bike = "Bikes";
this.bikeContent=["My First Bike","My Second Bike","My Third Bike"];
}
для кнопки Fxn в файле компонента: -
onBikeClick(){
this.isExpandedBikes =! this.isExpandedBikes;
}