点击按钮时," in"必须动态删除div元素。
<div class="container">
<h2>Simple Collapsible</h2>
<p>Click on the button to toggle between showing and hiding content.</p>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">Simple collapsible</button>
<div id="demo" class="collapse in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
</div>
</div>
答案 0 :(得分:1)
您可以在 app.component.ts 中指定一个布尔值,当点击该按钮时,更改true或false之间的值
<button (click)="isVisible = !isVisible">Toggle</button>
然后在div中添加以下内容
<div id="demo" [ngClass]="{'in': isVisible}" class="collapse">