ng-repeat嵌套和KeyValuePair列表

佳玛88

我的模型中有一个对象,其属性定义如下

List<KeyValuePair<DTO_AWTR, string>> AWTR_DRAWING

DTO_AWTR 是这样定义的另一个对象:

public partial class DTO_AWTR
{
    public string ITEM_NUMBER { get; set; }
    public string PLANT { get; set; }
    public string PLANT_EMAIL { get; set; }
}

在我看来,我想迭代将列表中的所有元素都扔掉,但是出现了问题。我看到了行数,但字段为空。

<table>
    <tr ng-repeat="draw in dataItem.AWTR_DRAWING">
        <td ng-repeat="(key, value2) in draw"></td>
        <td>{{ key.PLANT }}</td>               
    </tr>
</table>

您对这个问题有什么建议吗?

帕尔玛·夏尔马

您在此处提到的结构List<KeyValuePair<DTO_AWTR, string>> AWTR_DRAWING序列化为

[{key : {ITEM_NUMBER : "", PLANT : "", PLANT_EMAIL:""}, value : ""}, ...]

因此您应该使用ng-repeat牢记此结构。

<table>
    <tr ng-repeat="draw in dataItem.AWTR_DRAWING">
        <!--this will contain {key : {object structure}, value : ""} -->
        <td ng-repeat="(key, value2) in draw.key" ng-bind="key"></td>
        <!--this will contains key = "ITEM_NUMBER|PLANT|PLANT_EMAIL"-->              
    </tr>
</table>

**注意-根据js序列化程序,您可能使用的可能是newtonsoft json。对象键可能是驼色的

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章