通过AngularJS ng-repeat属性列出数组列表中数组列表的对象属性

时间:2016-02-27 06:45:02

标签: angularjs json

我有以下JSON数据

[Beds = [
    ElectricHospitalBed = [{name: 'Multifunctional electric hospital bed', code: 'IHC B/E 1001'},
        {name: 'Multifunctional electric hospital bed', code: 'IHC B/E 1002'},
        {name: 'Five functional electric hospital bed with ACP', code: 'IHC B/E 1003'},
        {name: 'Five functional electric hospital bed', code: 'IHC B/E 1004'},
        {name: 'Five functional electric hospital bed with ACP', code: 'IHC B/E 1005'},
        {name: 'Five functional electric hospital bed', code: 'IHC B/E 1006'},
        {name: 'Three functional electric hospital bed', code: 'IHC B/E 1007'},
        {name: 'Three functional electric hospital bed', code: 'IHC B/E 1008'},
        {name: 'Five functional electric hospital bed', code: 'IHC B/E 1009'}],
    Semi electric hospital bed = [],
    Manual hospital bed = [],
    Home care bed = [],
    Orthopedics bed = [],
    Childrens bed] = [],
Trollies = [Patient trolley = [],
    Stretcher = [],
    Nursing trolley [],
    Cambered trolley=[]]
]

我必须通过AngularJS ng-repeat属性列出产品的所有名称(假设每个对象都是产品)。请指教。

注意:此JSON数据被分配给名为ProductsData的控制器中名为products的变量。

2 个答案:

答案 0 :(得分:1)

就像[Beds = [{},{}],[{},{}],[{},{}], Trolleys = [],[],[],]

<div ng-repeat="c in products"> 
   <div ng-repeat="p in c"> 
   {{c.name}}
   </div>
</div>

c是产品类别,如床,手推车等

p是每个类别中的项目,

和c.name可以为您提供所需的信息。

答案 1 :(得分:0)

更正有问题的json格式。

无论如何,我在jsbin here

中进行了更改和建议