当前位置:  开发笔记 > 前端 > 正文

使用ng-repeat如何从嵌套的JSON对象中检索数据

如何解决《使用ng-repeat如何从嵌套的JSON对象中检索数据》经验,为你挑选了0个好方法。

在这里,我想使用Angular ng-repeat从嵌套的JSON对象中检索我的子文档数组数据

这是我的JSON嵌套对象:

[
    {
        _id: "5693bc169f5d75301ff5999d",
        booking: 
        [
            {
            can_name: "Kinley",
            can_quantity: "5",
            can_cost: "200",
            delivery_date: "12-01-2016",
            delivery_timeslot: "3pm-8pm",
            order_id: "18214",
            address: "140,Bajanai koil street, Melmanagar,Poonamallee,Chennai",
            _id: "5694926fd6227ee408b9d051",
            ordered_at: "2016-01-12T05:43:11.076Z",
            status: "UnderProcess"
            }
        ]
    },
    {
        _id: "5693baf07fe08c6012034b13",
        booking: 
        [
            {
            can_name: "Kinley",
            can_quantity: "4",
            can_cost: "160",
            delivery_date: "12-01-2016",
            delivery_timeslot: "3pm-8pm",
            order_id: "14426",
            address: "154,Pilliayar koil street,Poonamallee,Chennai",
            _id: "569491fad6227ee408b9d04f",
            ordered_at: "2016-01-12T05:41:14.531Z",
            status: "UnderProcess"
            },

            {
            can_name: "Bisleri",
            can_quantity: "5",
            can_cost: "250",
            delivery_date: "12-01-2016",
            delivery_timeslot: "3pm-8pm",
            order_id: "11391",
            address: "154,Pilliayar koil street,Poonamallee,Chennai",
            _id: "5694923ad6227ee408b9d050",
            ordered_at: "2016-01-12T05:42:18.900Z",
            status: "UnderProcess"
            }
        ]
    }
]

角度控制器代码:

$http.get('/auth/booking-date/' + id).success(function(response){
            $scope.todaylist = response;
            console.log(response);
            $scope.today = '';
        });

在这里,我如何使用ng-repeat来检索每个子文档数据.

这是我尝试过的,但我无法获得所有数据:

ID Address Can Name Can Quantity Can Cost Timeslot Delivery Date
{{today._id}} {{today.booking[0].address}} {{today.booking[0].can_name}} {{today.booking[0].can_quantity}} {{today.booking[0].can_cost}} {{today.booking[0].delivery_timeslot}} {{today.booking[0].delivery_date | date:'dd-MM-yyyy'}}

帮助将不胜感激......

见上文我发布了我的JSON数据而不是链接

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