【发布时间】:2019-10-02 16:20:31
【问题描述】:
我正在使用 Angular 7,但在理解管道语法的工作方式时遇到了一些问题。
到目前为止,这是我的代码:
tests: Row[]
public getTest() : Observable<Row[]> {
return this.http.get<Test[]>(this.testUrl)
.pipe(
map((tests) => {
tests.map(test => test.rows = this.tests)
return this.tests;
}))
}
这是我的模型:
export interface Test {
total_rows: number;
offset: number;
rows: Row[];
}
export interface Row {
id: string;
key: Key;
value?: any;
}
export interface Key {
name: string;
}
这是 JSON:
{
"total_rows": 2,
"offset": 0,
"rows": [
{
"id": "54229d6897e1d1c7d603428a850081d5",
"key": {
"name": "test1"
},
"value": null
},
{
"id": "54229d6897e1d1c7d603428a85010e03",
"key": {
"name": "test2"
},
"value": null
}
]
}
我想得到的数据是:一个行数组
感谢您的帮助
【问题讨论】:
标签: dictionary rxjs pipe observable angular7