我有一个生成的 json 对象槽
$json_str = file_get_contents('php://input'); echo json_encode($json_str);
看起来像:
0:[{"dok_1": "78",
"dok_45": "556",
"dok_e": "cde",
"dok_cd": "678",
"dok_bv": "5z",
"dok56": "rtz",
"dok_z6": "abc",
"dok_u8": "123"}]
我正在使用 Angular App Http Service 导入数据
onGetData() {return this.httpCient.get('https://www.mywebpage.com/...');}
users;
onGet() {this.httpService.onGetData().subscribe(data => this.users = data);}
效果很好。
如何将上述 json 对象存储在我的 http 服务或数据服务中?
有没有类似的东西
addData(users: object) {
this.users.push(data);
}
保存数据和
getData() {
return this.users;
}
取回数据?或者如何将 json 对象保存在 http 服务或数据服务中?我需要额外的数据服务还是 http 服务适合保存这个 json 对象?
以及如何循环通过 json 对象?
有没有类似的东西
<li *ngFor="let user of users">{{user}}</li>
? 但是我怎样才能访问键值以循环遍历每一行呢?