当前位置:  开发笔记 > 编程语言 > 正文

如何在ng-repeat中对JSON数据进行排序?

如何解决《如何在ng-repeat中对JSON数据进行排序?》经验,为你挑选了0个好方法。

我正在获取服务器响应并使用ng-repeat将这些数据绑定到视图.现在我想用priceList和排序这些数据name.我可以使用orderBy,但不能使用priceList.我想根据产品进行排序priceList.使用名称排序将改变列表的顺序,而排序priceList依次只会影响products每个列表的顺序category.它将影响显示类别的顺序.请帮我解决这个问题.
我的代码:

Sorting predicate = {{predicate}};

Name
`

{{vals.partTerminologyName}} : Position :{{vals.position}}

`
Quantity:{{val[0].perCarQty}}
part:{{val[0].partNo}}
sku:{{val[0].sku}}
qtyInStock:{{val[0].qtyInStock}}
priceList:{{val[0].priceList}}
priceSave:{{val[0].priceSave}}
qtyDC:{{val[0].qtyDC}}
qtyNetwork:{{val[0].qtyNetwork}}
priceCore:{{val[0].priceCore}}

JS:

$scope._JSON = [
        {"categories":
            [
                {"id":14061,"name":"Drive Belts",
                    "itemTypeResults":[
                        {"partTerminologyName":"Serp. Belt",
                            "position":"Main Drive",
                            "products":{
                                "5060635":[
                                    {"perCarQty":2,"partNo":"5060635",
                                    "sku":"20060904","qtyInStock":2,"qtyNetwork":4,
                                    "qtyDC":6,"priceList":19.15,"priceSave":3.29,
                                    "priceCore":10.0}
                                ],
                                "635K6":[
                                    {"perCarQty":9,"partNo":"635K6",
                                        "sku":"10062449","qtyInStock":2,"qtyNetwork":4,
                                        "qtyDC":6,"priceList":18.15,"priceSave":3.21,"priceCore":10.0}
                                ]
                            }
                        }
                    ]
                },
                {"id":2610,"name":"Drive Belt Tensioners, Idlers, Pulleys & Components",
                    "itemTypeResults":[
                        {"partTerminologyName":"Drive Belt Tensioner Assembly",
                        "position":"N/A",
                            "products":{
                                "950489A":[
                                    {"perCarQty":4,"partNo":"950489A",
                                        "sku":"10150833","qtyInStock":2,"qtyNetwork":4,
                                        "qtyDC":6,"priceList":18.15,"priceSave":3.21,"priceCore":10.0
                                    }
                                ]
                            }},
                        {"partTerminologyName":"Drive Belt Idler Pulley","position":"N/A",
                            "products":{
                                "89161":[
                                    {"perCarQty":1,"partNo":"89161",
                                    "sku":"99995959","qtyInStock":2,"qtyNetwork":4,
                                    "qtyDC":6,"priceList":17.15,"priceSave":3.21,"priceCore":10.0}
                                ],
                                "951373A":[
                                    {"perCarQty":2,"partNo":"951373A","pla":"LTN",
                                    "plaName":"Litens",
                                    "sku":"10150926","qtyInStock":2,"qtyNetwork":4,
                                        "qtyDC":6,"priceList":18.15,"priceSave":3.21,"priceCore":10.0}
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    ];
    $scope.predicate = '';

小提琴:小提琴

推荐阅读
刘美娥94662
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有