[英]How to display the object coming from API response using angular material table?
I have an object coming from response which looks something like .我有一个来自响应的 object,看起来像. It's a dynamic key value pair这是一个动态键值对
{
"name1": "value1",
"name2": "value2",
"name3": "value3"
............
............
}
I want to generate a material table from this.我想由此生成一个材料表。 I want to know how to get the response into my component file.我想知道如何将响应放入我的组件文件中。
I'm getting the response in my service file.我在我的服务文件中得到响应。
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class ApiService {
private headers = new Headers({ 'Content-Type': 'application/json' });
url: string = '';
constructor(private http:HttpClient) {
this.url = "https://beta.randomapi.com/api/3141b5683af0edf576dabdb50ef1ff64?fmt=prettyraw&sole";
}
public getData() {
return this.http.get(this.url )
.pipe(map((res: Response) => {
return res.json();
}));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.