我正在尝试获取数组内部的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