我正在努力验证从服务器检索到的空字符串
这通常很简单,只是不起作用
<div class="ui-g-2 info-txt"
*ngIf="appointment.Notes !==null ||
appointment.Notes !== ''">
<i class="fa fa-commenting-o" aria-hidden="true"</i>
</div>
<div class="ui-g-5 info-txt"
*ngIf="appointment.Notes !==null ||
appointment.Notes !== ''">
*emphasized text*{{appointment.Notes}}
</div>
<div class="ui-g-7 info-txt"
*ngIf="appointment.Notes === null ||
appointment.Notes === ''"
style="padding-top: 0;">
no hay notas disponibles
</div>
所以我正在检查一个空字符串或其中没有任何内容的字符串,问题是它仍然显示图标和空字符串
当没有干草里面有一条消息时.....没有显示所以它在那一边工作得很好
任何非常感谢的帮助一直停留在这个问题上。
我确定它很明显我只是看不到它
最佳答案
您可以使用双重否定来检查值是否未定义/空或空。
例如:*ngIf="!!name"。
这将防止显示所有 Null、未定义或空值。
关于angular - Ngif 用于空字符串验证 Angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53107942/