如何使用ng-repeat来呈现此JSON数据?

时间:2014-12-11 12:07:29

标签: angularjs ng-repeat

如何仅使用ng-repeat

重复下面的JSON而不使用for for循环
$scope.cart = {
    "product": [
        {
        "HH_STYLENUM": "2204-RYP",
        "SIZE_QTY": [
            { "QTY": "11", "SIZE": "XS" },
            { "QTY": "11", "SIZE": "XL" },
            { "QTY": "111", "SIZE": "S" },
            { "QTY": "111", "SIZE": "M" },
            { "QTY": "111", "SIZE": "L" }
        ],
        "HH_CUSTID": "2919",
        "HH_ADDCART_UNITPRICE": "11.5",
        "HH_ADDCART_NO": "188",
        "HH_ADDCART_DATE": "2014-12-10 00:25:07.0",
        "HH_ADDCART_STATUS": "CART",
        "HH_COLORID": "15991"
        },
        {
        "HH_STYLENUM": "2204-HHSH",
        "SIZE_QTY": [
            { "QTY": "01", "SIZE": "XS" },
            { "QTY": "03", "SIZE": "XL" },
            { "QTY": "104", "SIZE": "S" },
            { "QTY": "51", "SIZE": "M" },
            { "QTY": "31", "SIZE": "L" }
        ],
        "HH_CUSTID": "2919",
        "HH_ADDCART_UNITPRICE": "11.5",
        "HH_ADDCART_NO": "188",
        "HH_ADDCART_DATE": "2014-12-10 00:25:07.0",
        "HH_ADDCART_STATUS": "CART",
        "HH_COLORID": "15991"
        }
    ]
};

1 个答案:

答案 0 :(得分:0)

根据您的评论...您可以使用两次ng重复。一个循环在cart.product上并在ng-repeat中,另一个ng-repeat循环遍历SIZE_QTY

<div ng-repeat="product in cart.product">
      <p ng-repeat="size in product.SIZE_QTY">{{size.SIZE}}</p>