I've recently started working with Angular and I'm encountering an issue when trying to pass the _newArray
to my child component using a shared service.
Service
fetchData(): Observable < any > {
return forkJoin(this.fetchQuestions(), this.retrieveData()).pipe(
tap(data => {
this.combineData(this._questionsArray, this._dataArray);
})
);
}
combineData(question, data): any[]{
let _newArray: any[] = [];
_newArray.push({
test1: "test1",
test2: "test2"
});
return _newArray
}
Component
export class DisplayComponent implements OnInit {
_updatedArr: any[];
constructor(private apiService: ApiService) { }
ngOnInit(): void {
this.apiService.fetchData()
.subscribe(data => {
this._updatedArr = data;
});
}
}