英文:
Angular 2 Have method print out svg polygon points
问题
我有一个简单的方法,它会打印一些SVG多边形的点坐标:
printOutSVGFormat() {
var andrew = "200,10 250,190 160,210";
return andrew;
}
而模板如下所示:
<div class="svgWalkableArea">
<svg height="210" width="500">
<polygon [points]="printOutSVGFormat()" style="fill:lime;stroke:purple;stroke-width:1" />
</svg>
</div>
然而,Angular 报错如下:
无法绑定到 'points',因为它不是 ':svg:polygon' 的已知属性。
有关如何解决这个问题的想法吗?
英文:
I have a simple method which prints out some svg polygon points:
printOutSVGFormat() {
var andrew = "200,10 250,190 160,210";
return andrew;
}
And the template is shown below:
<div class="svgWalkableArea">
<svg height="210" width="500">
<polygon [points]="printOutSVGFormat()" style="fill:lime;stroke:purple;stroke-width:1" />
</svg>
</div>
However Angular errors with the following code:
Can't bind to 'points' since it isn't a known property of ':svg:polygon'
Any ideas on how I can get around this?
答案1
得分: 2
尝试 attr.points
<polygon [attr.points]="printOutSVGFormat()" style="fill:lime;stroke:purple;stroke-width:1" />
英文:
Try attr.points
<polygon [attr.points]="printOutSVGFormat()" style="fill:lime;stroke:purple;stroke-width:1" />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论