如何获取数组中的值-Angular

时间:2020-06-26 00:26:27

标签: typescript angular6

我正在尝试获取数组内部的id,但是当我运行代码时,我得到的是不确定的值

API请求

this.servercall()
    .subscribe(response => {
        "type":this.Response [= response;
        this.typesResponse = this.Response.types.type
      {
       console.log (this.typesResponse)


export interface Result {
      
      types: Types;
      Id: any[];
    }



export interface Types{
  type: any[]
}

export interface Type{
id: string[]
}

这是json文件的示例

{

        "types": {
    
            "type": [
                {
                    "id": "motorcycle "                                
                    "color": "yellow" "
                }
     {
                    "id": "car "                                
                    "color": "red" "
                }
        }

HTML

<pre>{{this.typesResponse}}</pre> 

现在我可以从数组中获取值并将其传递给html

0 个答案:

没有答案