2
我想创建一个饼图的图例和关键字,并在它旁边的图形和文本中使用相同颜色的小圆圈。然而,这是当我尝试这样做,我得到的错误:Angular2 * ngFor与SVG圈
“模板解析错误: 不能绑定到‘补’,因为它不是一个已知的原生属性”
以下是我的代码:
<svg *ngFor="let item of items;" width="250" height="75">
<circle cx="50" cy="50" r="20" fill={{item.color}} />
<text x="100" y="50">{{item.name}}</text>
</svg>
item.color和item.name都是字符串,当我试图只显示它们作为文本时,所有的值都会出现。
有谁知道我该如何解决这个错误?
尝试'补= “{{item.color}}”' –
或'所有[填补] = “item.color”' – peinearydevelopment
谢谢!我可以用[attr.fill] =“item.color” – Alan