我订阅了一个 observable (getContentfulEntry) 来获取一些数据,但也从另一个 observable (stateService) 传递数据
this.langSubscription = this.stateService.getLanguage()
.subscribe(val => {
this.lang = val;
});
this.subscription = this.contentfulService.getContentfulEntry(this.footerEntryId, {locale: this.lang.toLowerCase()})
.subscribe(res => {
console.log('Footer Entries:: ', res);
// this.contentfulData = res;
this.filteredFooter = this.contentfulService.getFilteredEntryByProv(res, this.prov);
console.log('Filtered Footer:: ', this.filteredFooter);
});
将其作为参数。因此,当 this.lang 更新时会获取新数据。但是,除非我点击刷新,否则 this.subscription 不会更新视图中的数据。知道我做错了什么或如何解决这个问题吗?