src/shared.service.ts
public _testData:any;
set testData(value:any) {
this._testData = value
}
get testData():any {
return this._testData;
}
src/header.component.ts
private postValues() {
this._PartService.PostDataValues(this.search).subscribe(
result => {
this.sharedService._testData
})
}
onSearch() {
this.postValues()
}
src/home.component.ts
private downloadRecentSearches() {
this.recentSearchService.download().subscribe(
searches => {
this.resultData = searches;
this.originalSearches = this.resultData.data;
this.sharedService._testData = this.originalSearches
this.onSelectItem()
})
}
The code snippet above involves assigning the result to "this.sharedService._testData". In the header component, upon clicking search, the new search result is saved and needs to be updated in the home component. However, there is uncertainty regarding how to navigate back to the home component to retrieve the latest search results.