【发布时间】:2019-08-01 02:26:02
【问题描述】:
我正在查看有关 Angular 的 HttpClient (https://angular.io/guide/http#error-handling) 的文档并遇到了这个 sn-p:
showConfig() {
this.configService.getConfig()
.subscribe(
(data: Config) => this.config = { ...data }, // success path
error => this.error = error // error path
);
}
我很好奇为什么data 对象在分配给config 属性之前会被传播。与简单地将数据对象直接分配给this.config相比,这样做有什么优势?
【问题讨论】:
标签: angular2-observables angular-httpclient