如何使用ng-repeat设置动态创建的宽度

时间:2016-04-13 05:23:16

标签: angularjs angularjs-ng-repeat

我正在创建一个像这样的表的动态标题:

@Override
public Object convertFromString(Map context, String[] value, Class arg2) {
    String val = value[0];      

    try {
        return ASEEncDecUtil.encrypt(val.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return null;
    }

}

但是“header.width”没有应用,因为它与ng-repeat在同一个元素中。

那么解决这个问题的方法是什么?

请指导我。

谢谢。

2 个答案:

答案 0 :(得分:3)

使用花括号:

<th class="header" data-href="" rel="tooltip" title="" ng-repeat="header in tableHeaders" width="{{header.width}}">

答案 1 :(得分:1)

试试这个

 <th title="" ng-repeat="header in tableHeaders" ng-style="{'width': header.width}">