I am attempting to pass the alpha2code variable through another component so that when a row in my table is clicked, it should display data specific to the alpha2code.
This is the function that is triggered when a specific row in the table is clicked:
onRowClicked(row) {
console.log('Row clicked: ', row);
console.log(row.alpha2Code);
this.setData(row.alpha2Code);
location.href="/country";
}
Here is the setter used to assign the alpha2code from the row to the value in my service:
set setData(value: any) {
this.getService.alpha2Code = value;
}
My service:
export class GetCountries {
alpha2Code : any;
constructor(private http: HttpClient) { }
public GetAllStationCountries(){
return this.http.get('https://restcountries.eu/rest/v2/all');
}
}
In my child component, I am trying to bind the value from my parent component to my child, which has already been set:
public get data():any {
return this.getService.alpha2Code;
}
If I am doing something incorrectly, please let me know. My main goal was to pass data from the parent component to the child component so that I could retrieve country information from the API using the alpha2code parameter, ultimately creating a dashboard with detailed information about the country clicked in the table.