json - Angular HTTP Res JSON 数据以 html 格式打印
问题描述
下面是 HTTP 获取请求响应。我如何使用 *ngFor 在视图中打印相同的内容。我正在尝试在控制台中打印像 data[0].value1 这样的单个对象打印。它返回未定义。内部数据数组 3 个 JSON 对象。还有一些数组
非常感谢任何帮助...
getEmp(){
this.EmpService.getAccounts().subscribe((res : any[])=>{
this.products = JSON.stringify(res);
});
.
{
"data": [
{
"value1": "3546786908765432",
"category": "Clothing (Brand)",
"category_list": [
{
"id": "001",
"name": "Clothing (Brand)"
},
{
"id": "39324324230",
"name": "Boutique Store"
},
{
"id": "12342324324",
"name": "Website"
}
],
"name": "wqeqws",
"id": "qwsqwsq w",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
},
{
"value1": "111-9=-09876543",
"category": "Education",
"category_list": [
{
"id": "23456",
"name": "Education"
}
],
"name": "sdcsfcsdfvsd",
"id": "111111111111",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
}
],
"paging": {
"cursors": {
"before": "dsfsds",
"after": "sdfsfs"
}
}
}
解决方案
this.products = res.data;
在您的页面中
< *ngFor="let item of products >
推荐阅读
- javascript - 如何添加弹出窗口
- c - 如何让我的灯光相对于我的场景(在立方体中)保持固定?
- python - 创建唯一列表
- computer-vision - tesseract - 如何处理字符分隔符
- node.js - 添加许多异步作业时,Node.js 变得非常慢
- android - SecurityException: Permission Denial 即使我正在获取运行时权限
- python - 是什么导致 http 请求覆盖由 file.write() 创建的内部缓冲区?
- vb.net - 背景图片移动 vb.net
- php - 如何在 Laravel 5.6 中使用车辆 user_id 打印用户电子邮件
- mongodb - Mongo DB 聚合管道