我正在努力了解如何创建一个如果显示一个ng内容是空的.
<div #contentWrapper [hidden]="isOpen"> <ng-content ></ng-content> </div> <span *ngIf="contentWrapper.childNodes.length == 0"> <p>Display this if ng-content is empty!</p> </span>
当内容为空时,我尝试使用该显示数据显示数据,但即使信息为空,也不会显示< span>标签
谢谢,永远感谢您的帮助.
使用子代替childNode. Angular为* ngIf *创建注释节点,这些节点由childNodes`计数
<div #contentWrapper [hidden]="isOpen"> <ng-content ></ng-content> </div> <span *ngIf="contentWrapper.children.length == 0"> <p>Display this if ng-content is empty!</p> </span>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。