【发布时间】:2017-07-02 03:49:19
【问题描述】:
根据我对文档的解释,如果我希望能够默认隐藏一个元素,并在单击链接时显示,那么以下应该可以工作吗?
-
在 /app/app.component.ts 中
newTrustFormVisible: false; -
在 /app/app.component.html 中
<a href="#" (click)="newTrustFormVisible = !newTrustFormVisible;">[Add New]</a> <div ng-show="newTrustFormVisible" class="panel panel-default"> ... </div>
但是,这不起作用。它也不会产生错误。我错过了什么?
【问题讨论】:
-
我也尝试过
newTrustFormVisible: boolean = false;,我认为这实际上是该行的正确语法,尽管它对结果没有任何影响。
标签: javascript html angular typescript