从我的火力点数据库,我得到这个JSON数据
categories= [
{
"laptops" : [ null,
{
"category" : "laptops",
"description" : "ggg",
"title" : "Nexus" <-- I want this value but i canot do that pls help me
},
{
"category" : "laptops",
"description" : "nnn",
"title" : "HP"
},
{
"category" : "laptops",
"description" : "mmm",
"title" : "Microsoft"
},
{
"category" : "laptops",
"description" : "mmm",
"title" : "Razer"
}
],
},
{
"tablets" : [ null,
{
"category" : "tablets",
"description" : "uuu",
"title" : "Iphone"
},
{
"category" : "tablets",
"description" : "bbb",
"title" : "Intel"
}
]
}
]
在我app.component.html
<div *ngFor="let category of categories; let i = index;" id="{{category.$key}}">
</div>
并给我- > 笔记本电脑和平板电脑
一切正常,但我怎么也无法得到类别的标题 - >平板电脑
我有这样的代码,但不工作我得到的翻译:
我想 - >
<div *ngFor="let category0 of categorys; let i = index;" id="{{category0.$key}}">
<div>{{i}}</div>
<div *ngFor="let category1 of category0[i]; let ii = index;">
{{category1}}
<div>{{ii}}</div>
<div *ngFor="let category2 of category1[ii]; let iii = index;">
{{category2.title}}
<div>{{iii}}</div>
</div>
</div>
</div>
这是输出
0 [对象的对象] 1 [对象的对象] 2 [对象的对象] 3 [对象的对象] 4
这是在控制台上的错误
AdminProductsComponent.html:92 ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngOnChanges (common.es5.js:1689)
at checkAndUpdateDirectiveInline (core.es5.js:10790)
at checkAndUpdateNodeInline (core.es5.js:12216)
at checkAndUpdateNode (core.es5.js:12155)
at debugCheckAndUpdateNode (core.es5.js:12858)
at debugCheckDirectivesFn (core.es5.js:12799)
at Object.eval [as updateDirectives] (AdminProductsComponent.html:92)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:12784)
at checkAndUpdateView (core.es5.js:12122)
at callViewAction (core.es5.js:12485)