【问题标题】:How can I add Interpolation to get the width for LI?如何添加插值以获得 LI 的宽度?
【发布时间】:2020-12-19 01:32:31
【问题描述】:

我想将 {{getCount(userObj.assigned_to, 'Applicable')}} + px 的相同值带到具有背景颜色的类的 LI 宽度,但是一旦我将相同的值添加到 style.width 就会出错。

Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 1

<li class="chart__bar" [style.width]="{{getCount(userObj.assigned_to, 'Applicable')}}">{{getCount(userObj.assigned_to, 'Applicable')}}</li>

请建议如何获得 li 宽度。

【问题讨论】:

    标签: html css angular interpolation


    【解决方案1】:
    <li class="chart__bar" [ngStyle]="{'width': (getCount(userObj.assigned_to, 'Applicable')*10)+ '%'}">{{getCount(userObj.assigned_to, 'Applicable')}}</li>
    

    【讨论】:

      猜你喜欢
      • 2011-03-01
      • 2023-03-10
      • 2014-03-27
      • 2011-07-29
      • 1970-01-01
      • 2015-10-25
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多