注意:我想插入数据而不将其写入.json文件。例如Angularfire2数据库。
user = {
name: 'Arthur',
age: 21
};
const options = {Headers, responseType: 'json' as 'blob'};
this.httpService.put('assets/data/ex.json', this.user, options).subscribe(
data => {
console.log(data);
},
(err: HttpErrorResponse) => {
console.log (err.message);
}
);
答案 0 :(得分:0)
您可以使用点运算符直接访问对象
user = {
name: 'Arthur',
age: 21
};
const options = {Headers, responseType: 'json' as 'blob'};
this.httpService.put('assets/data/ex.json', this.user, options).subscribe(
data => {
console.log(data);
data.user.lastName ='stackoverflow';
},
(err: HttpErrorResponse) => {
console.log (err.message);
}
);