【发布时间】:2018-04-20 20:25:44
【问题描述】:
这是我的 JSON 数据:
[
{
"id": 1,
"label": "saw",
"total": "100"
},
{
"id": 2,
"label": "saw1",
"total": "300"
},
{
"id": 3,
"label": "saw2",
"total": "400"
}
]
这是我的打字稿
this.http.get('http://www/upnionic/chart.php')
.map(res => res.json()).subscribe(data => {
this.qwerty = data; this.qwerty.forEach(element => {
let product = element.total;
this.pieChartData = product;
console.log(product);
});
});
如何在 HTML ionic 2 中获取这样的视图数据 Json ?
["100","300","400"]
【问题讨论】:
-
var totalArray = data.map((item) => item.total); -
成功了!!!!,非常感谢
标签: json typescript charts ionic2 ionic3