I am looking to store backend data in a variable called scores.
The data from the backend is currently stored as scores1
:
(5) [Array(4), Array(4), Array(4), Array(4), Array(4)]
0: (4) ["fake algorithm 1", "fake_scalar_1", "none", 0.679]
1: (4) ["csic's algorithm", "fake_time_series_1", "mean", 0.954]
2: (4) ["csic's algorithm", "step_length_right", "mean", 0.654]
3: (4) ["csic's algorithm", "step_length_left", "mean", 0.351]
4: (4) ["csic's algorithm", "step_time_right", "mean", 0.378]
We want to transfer this data into our scores object.
Components.ts:
experiment1: scores[] = [];
id1: number;
id2: number;
selectedExperiments: number[];
scores1: any;
ngOnInit() {
this.selectedExperiments = this.experimentService.getTheId();
console.log(this.selectedExperiments);
this.id1 = this.selectedExperiments[0];
this.id2 = this.selectedExperiments[1];
this.compareService.getScore(this.id1)
.subscribe(response => {
this.scores1 = response;
for(var i = 0; i<(this.scores1.length-1);i++){
this.experiment1[i].algorithm_name=this.scores1[i][0];
this.experiment1[i].pi_name=this.scores1[i][1];
this.experiment1[i].agg_type=this.scores1[i][2];
this.experiment1[i].score=this.scores1[i][3];
console.log(this.experiment1[i]);
}
}
);
this.compareService.getScore(this.id2)
.subscribe(response => {
this.scores2 = response;
console.log(this.scores2)}
);
}
Using the scores class:
export class scores {
public algorithm_name: string;
public pi_name: string;
public agg_type: string;
public score: number;
}
Currently, I'm facing an issue where it doesn't recognize the algorithm name...
The getScore()
method from the service is functioning correctly, and using console.log()
, I can see the data above.