我想将数据分享到两个变量,项目和标题,我该如何实现?
items = [];
title = [];
ngOnInit() {
this.dataService.fetchData(this.id)
.subscribe(
(data) => this.items = data,
(error) => handleError(error),
);
}
答案 0 :(得分:4)
ngOnInit() {
this.dataService.fetchData(this.id)
.subscribe(
(data) => {
this.items = data;
this.title = data;
},
(error) => handleError(error),
);
}
答案 1 :(得分:3)
this.dataService.fetchData(this.id)
.subscribe(
(data) => this.items = this.title = data,
(error) => handleError(error),
);