gpt4 book ai didi

Angular 2 : If value exists show html

转载 作者:行者123 更新时间:2023-12-02 16:14:58 25 4
gpt4 key购买 nike

目前,我有一个服务可以从我编写的许多 API 中提取值。在模板中,我希望仅在将结果馈送到模板时,如果值存在或不为空,则输出以下 html:

<li class="title rh-blue-lite-fg">{{ project.meta_header_one }}</li>

所以我试图弄清楚如何将其包装在 ngIf 中,或者是否有其他方法可以做到这一点,以便这个“li”项目仅在该值存在且不为空时才获得输出

最佳答案

我认为你可以使用 ngIF 指令来检查项目是否不为空:

<li class="title rh-blue-lite-fg" *ngIf="project.meta_header_one">{{ project.meta_header_one }}</li>

引用: https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html

关于 Angular 2 : If value exists show html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37500107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com