简体   繁体   English

找不到'对象'类型的不同支持对象'[object Object]'

[英]Cannot find a differ supporting object '[object Object]' of type 'object'

I am working on angular 2 application, in my current project I am getting the data from my API and It's gives the JSON like below. 我正在开发angular 2应用程序,在我当前的项目中,我从我的API获取数据,它给出了如下的JSON。

{
    "makes": null,
    "models": null,
    "trims": null,
    "years": null,
    "assetTypes": {
        "2": "Auto",
        "3": "Motorcycle"
    }
}

Next I am converting the JSON data to typescript using json2ts tool from this link http://json2ts.com/ 接下来我将使用json2ts工具将JSON数据转换为typescript来自此链接http://json2ts.com/

Typescript.ts Typescript.ts

export interface AssetTypes {
    2: string;
    3: string;
}

export interface RootObject {
    makes?: any;
    models?: any;
    trims?: any;
    years?: any;
    assetTypes: AssetTypes;
}

Then After I will use below lines of code In my component.ts 然后我将在我的component.ts中使用下面的代码行

 lookupdetailsassettypeinfo: RootObject;
 this._vehicleInfoService.getLookupDetailsTableAssetTypeInfo()
        .subscribe(lookupdetailsinfo => this.lookupdetailsassettypeinfo = lookupdetailsinfo,
        error => this.error = <any>error);

But when I am using the lookupdetailsassettypeinfo in my component.html like this below. 但是,当我用我component.html这样下面的lookupdetailsassettypeinfo。 it always gives the exception like Cannot find a differ supporting object '[object Object]' of type 'object'. 它总是给出异常,例如找不到'object'类型的不同支持对象'[object Object]'。 NgFor only supports binding to Iterables such as Arrays. NgFor仅支持绑定到诸如Arrays之类的Iterables。

<select id="ASSET_TYPE" class="col-md-12 form-control" >
    <option>Select One</option>
    <option *ngFor='let type of lookupdetailsassettypeinfo'>{{type.assetTypes.Customer}}</option>
</select> 

Can you please tell me how to resolve the above exception. 你能告诉我如何解决上述异常吗?

-Pradeep -Pradeep

*ngFor doesn't support iterating over object properties. *ngFor不支持迭代对象属性。 It only supports arrays. 它只支持数组。

See also Access Typescript Object Variables in Angular2 另请参阅Angular2中的Access Typescript对象变量

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到其他支持对象&#39;[对象对象] - Cannot find a differ supporting object '[object Object] Angular:*ngFor 循环给我错误:找不到类型为“object”的不同支持对象“[object Object]” - Angular: *ngFor loop giving me error: Cannot find a differ supporting object '[object Object]' of type 'object' 过滤多面阵列,但管道返回错误 - 找不到&#39;对象&#39;类型的不同支持对象&#39;[object Object]&#39; - Filtering a multifaceted array, but the pipe return an error - Cannot find a differ supporting object '[object Object]' of type 'object' 角度4无法找到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - Angular 4 Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays Angular 9 找不到支持“对象”类型的 object“[对象对象]”的不同。 NgFor 仅支持绑定到诸如 Arrays 之类的 Iterables - Angular 9 Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 找不到类型为“object”的不同支持对象“[object Object]”。 - 上下文菜单问题 - Cannot find a differ supporting object '[object Object]' of type 'object'. - context menu issues Angular 12:找不到支持 object 类型为“object”的“[object Object]” - Angular 12: Cannot find a differ supporting object '[object Object]' of type 'object' 找不到类型为“数字”的不同支持对象“33.265625” - Cannot find a differ supporting object '33.265625' of type 'number' Angular 问题:找不到支持“object”类型的 object“[object Object]”的不同。 NgFor 仅支持绑定到诸如 Arrays 之类的 Iterables - Angular problem: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 错误:找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到Iterables(如数组)如何解决 - error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays how to solve
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM