【发布时间】:2023-03-29 22:49:02
【问题描述】:
我想通过单击一个按钮来显示或隐藏一个部分。我不想在控制器中创建变量。有没有办法通过使用本地模板变量(使用#variableName)来做到这一点?
我在想像下面这样的事情。
但为此我得到template parse error。
<button color="primary" #showSection1="true" (click)="!showSection1;">Toggle</button>
<p *ngIf="showSection1">
This should be shown or hidden on click of the button.
</p>
【问题讨论】: