angular - Angular Clarity Icon 无法绑定到 ngFor 循环中的 CSS 形状属性
问题描述
我正在尝试建立一个链接列表,其中链接是从休息调用中提供的。生成的链接列表将包含一个 URL 和一个类型标识符。我正在尝试使用 ngFor 循环显示图标,并且正在使用库存的 Clarity 图标集:
<ng-template ngFor let-link [ngForOf]="links" let-j="index" >
<clr-icon shape={{link.icon}} height="42" width="42"></clr-icon>
...
但是,当我运行它时,我得到:
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'shape' since it isn't a known property of 'clr-icon'.
1. If 'clr-icon' is an Angular component and it has 'shape' input, then verify that it is part of this module.
2. If 'clr-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
在这种情况下,有没有办法将形状绑定到图标,或者 CSS 属性是不行的?
解决方案
你必须使用属性绑定来做到这一点。
<clr-icon [attr.shape]="link.icon" height="42" width="42"></clr-icon>
推荐阅读
- flutter - 绕过最小 SDK 版本 - 还是什么?
- javascript - How to call function from other local file Node.js?
- java - 读取带有非法字符的 Parquet 文件 (Apache-Avro)
- asp.net-core - ASP .NET Core Web API 在 IIS 中加载 32 位库导致启用 32 位的 BadImageFormatException
- f# - F# 在 VS 构建工具 2019 16.6.0 中损坏
- web-scraping - Scrapy:无法使用css选择器提取属性字段
- python - 如何以编程方式在 matplolib FigureCanvas 中设置视图?
- ansible - ansible 检查 lineinfile 的字符串失败
- html - 多列上的换行符
- google-sheets-query - Google Query Language 中是否有 dateadd 标量函数?