I am fetching data from PHP API, But the variable after subscribe is empty in component.ts but, while using in component.html it displays data. I want to modify after fetching from API.
In service.ts:
get_tournaments(){
return this.http.get("http://localhost/Website/api/tournament/read.php")
.map(res=>res.json());
}
In component.ts:
tournaments:Object[] = [];
ngOnInit() {
this.ongoing_ser.get_tournaments()
.subscribe(value=>this.tournaments=value);
console.log("Main:",this.tournaments); <-- this is empty
}
In component.html:
it displays everything correct as required.
I want to modify the data fetched from API and then display in html