我正在使用*ngIf
来有条件地显示一段可以正常工作的代码块。
但是我需要使用[hidden]
或display:none
来实际隐藏dom中的块。据我了解,我只能提供true
或false
[hidden]
。
如何使用[hidden]
或[class]
从Dom中有条件地隐藏此内容?
<div *ngIf="raid != -1;">
<p>Need to display:none inside of this</p>
</div>
答案 0 :(得分:1)
您必须在标记中添加隐藏选项:
<p [hidden]="true">Need to display:none inside of this</p>
并用变量名
替换“”中的true或者如果您只想隐藏文本的一部分:
<p>some text <span [hidden]="true">this will be hidden (or not) </span>some more text</p>