I load data in AppComponent
and then refer to this data in people.component
But people.component loads first.
AppComponent
ngOnInit() {
pre: this.getPeople();
}
getPeople(): any {
this.getDATA(this.URL)
.subscribe(people => {
this.people = people,
console.log(people[0]);
});
}
people.component
ngOnInit() {
pre: this.people = this.appData.people;
this.getPeople();
}
getPeople(): any {
console.log("people.component getPeople()");
}
The console display "people.component getPeople()" before it displays the first element of the people array.
So, I can't leverage the people array in the people component.
Any ideas on how to get the AppComponent to run before the people.component?