【问题标题】:Angular js Bind a variable into tag <text x =Angular js 将变量绑定到标签 <text x =
【发布时间】:2023-03-22 03:52:01
【问题描述】:

我正在尝试将我范围内的值传递到 x: 的文本标记中:

<g transform="translate(150,40)">
  <rect ng-style="{'width':info}" height="39" fill="#66CC99"></rect>
  <text x={{info}} y="9.5" dy="1.2em" dx="-5px">{{infoNum}}</text>
</g>

但我得到了错误:

> Error: <text> attribute x: Expected length, "{{info…".

我该如何解决这个问题?有没有办法将变量正确绑定到 x 参数?方法:ng-style="{'x':info}" 不起作用。

【问题讨论】:

    标签: html css angularjs svg


    【解决方案1】:

    试试ng-attr

    <text ng-attr-x="{{info}}" y="9.5" dy="1.2em" dx="-5px">{{infoNum}}</text>
    

    另外,请查看this answer

    【讨论】:

      猜你喜欢
      • 2014-07-06
      • 2011-03-09
      • 2012-01-12
      • 1970-01-01
      • 2018-07-11
      • 2016-03-29
      • 1970-01-01
      • 2015-06-30
      • 2016-12-16
      相关资源
      最近更新 更多