I am trying to pass an array from one child component to another. I have tried following some of the tutorials online to share data with a service, but this doesn't seem to be working for me and causes my page not to load anything.
What was breaking 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);
}
}