如何实施操作以打开与每个div
相关联的每个button
?
我有html
<ol *ngFor="let g of guides">
<button type="button" class="form-control" (click)="open(g)">{{g.description}}</button>
<div [hidden]="!canOpen" style="text-align: center">test</div>
</ol>
</div>
哪个变量canOpen
是整个component
?
答案 0 :(得分:0)
我认为这可以帮到你:
模板面:
<button (click)="openAll()">Toggle Div</button>
<ol *ngFor="let g of guides">
<button type="button" class="form-control" (click)="open(g)">{{g.description}}</button>
<div [hidden]="!canOpen || openAllDiv" style="text-align: center">test</div>
</ol>
组件方:
openAllDiv = false;
openAll() {
this.openAllDiv = !this.openAllDiv;
}