I've been attempting to pass an array from one child component to another without success. Despite following various online tutorials on using a service to share data, my page fails to load anything.
The issue that was causing problems in my program was adding the DataService to the constructor:
import { DataService } from '../data.service';
export class BodyComponent implements OnInit{
films = [{Title: "Finding Nemo", Rating: "3.5"}, {Title: "Rambo", Rating: "4.0"}];
constructor(private http: HttpClient, private data: DataService) { }
}
data.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable()
export class DataService {
private finalNoms = new BehaviorSubject<any>([]);
currentNoms = this.finalNoms.asObservable();
constructor() { }
changeNominations(nom: Object){
this.finalNoms.next(nom);
}
}