双重角度2与SVG [英] Double binding angular 2 with SVG
本文介绍了双重角度2与SVG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< rect x = {{rect。 x}} y = {{rect.y}} width = {{rect.width}} height = {{rect.height}} fill = {{rect.fill}} stroke = {{rect.stroke}} /> ;
< path [d] =M0,0 v rect.height h rect.width v- rect.height z/>
解决方案
这应该工作
< rect [attr.x] =rect.x[attr.y] =rect.y[attr.width] =rect。宽度[attr.height] =rect.height
[attr.fill] =rect.fill[attr.stroke] =rect.stroke/>
x = {{rect.x}}
(相当于 [x] =rect.x
是属性绑定语法,但这些SVG属性需要属性绑定。
I am writing an Angular 2 application, And i can't understand why Angular can not properly work with <svg>. When i try to make SVG elements active with angular, i see errors in console.
<rect x={{rect.x}} y={{rect.y}} width={{rect.width}} height={{rect.height}} fill={{rect.fill}} stroke={{rect.stroke}} />
<path [d]="M0,0 v rect.height h rect.width v- rect.height z" />
解决方案
This should work
<rect [attr.x]="rect.x" [attr.y]="rect.y" [attr.width]="rect.width" [attr.height]="rect.height"
[attr.fill]="rect.fill" [attr.stroke]="rect.stroke" />
x={{rect.x}}
(equivalent to [x]="rect.x"
is property binding syntax but these SVG attributes need attribute binding.
这篇关于双重角度2与SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文